citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.57k stars 2.11k forks source link

[MonoV2] Event listeners with a byte[] as a parameter fail to register #2571

Open ruigouveiamaciel opened 5 months ago

ruigouveiamaciel commented 5 months ago

What happened?

Events that take byte arrays as a parameter fail when registering (past build 8380).

public class ExampleServerScript : BaseScript
{
    [EventHandler("exampleEvent", Binding.Remote)]
    private static void HandleIncomingRequest([Source] Player player, byte[] data)
    {
        Debug.WriteLine("Hello World");
    }
}
[rcon/script:Placehol] Registering CitizenFX.Core.EventHandler PlaceholderRP.Server.Hooks.Hooks.HandleIncomingRequest failed with exception: System.ArgumentException: Bad type def, can't handle '>' at 28
[rcon/script:Placehol] Parameter name: typeName
[rcon/script:Placehol]   at System.TypeSpec.Parse (System.String name, System.Int32& p, System.Boolean is_recurse, System.Boolean allow_aqn) [0x004f5] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at System.TypeSpec.Parse (System.String typeName) [0x00010] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at System.Reflection.Emit.ModuleBuilder.GetType (System.String className, System.Boolean throwOnError, System.Boolean ignoreCase) [0x00037] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at System.Reflection.Emit.ModuleBuilder.GetType (System.String className) [0x00000] in <fbc4ec45371543bfba3678ebb82caf6d>:0
[rcon/script:Placehol]   at CitizenFX.MsgPack.Formatters.ArrayFormatter.Build (System.Type type, System.Type typeArray) [0x00016] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\Formatters\ArrayFormatter.cs:17
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackRegistry.CreateSerializer (System.Type type) [0x0002a] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:190
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackRegistry.GetOrCreateDeserializer (System.Type type) [0x00000] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackRegistry.cs:174
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackDeserializer.ConstructDelegate (System.Object target, System.Reflection.MethodInfo method) [0x0022b] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackFunc.cs:124
[rcon/script:Placehol]   at CitizenFX.MsgPack.MsgPackDeserializer.CreateDelegate (System.Object target, System.Reflection.MethodInfo method) [0x000a0] in C:\gl\builds\cfx-fivem\master\fxserver\vendor\msgpack-cs\MsgPack\MsgPackFunc.cs:39
[rcon/script:Placehol]   at CitizenFX.Core.BaseScript.Initialize () [0x000a4] in C:\gl\builds\cfx-fivem\master\fxserver\code\client\clrcore-v2\BaseScript.cs:97
[rcon/script:Placehol] Instantiated instance of script PlaceholderRP.Server.AdminQOL.AdminCommands.

Expected result

Event should not fail to register

Reproduction steps

  1. Use build 8385 of FxServer

  2. Make a resource that uses MonoV2

  3. Add this script to your resource and watch the server/client fail to register it

public class ExampleServerScript : BaseScript
{
    [EventHandler("exampleEvent", Binding.Remote)]
    private static void HandleIncomingRequest(Player player, byte[] data)
    {
        Debug.WriteLine("Hello World");
    }
}

Importancy

Slight inconvenience

Area(s)

ScRT: C#

Specific version(s)

Server 8380 Windows

Additional information

No response

FabianTerhorst commented 4 months ago

Try again on latest build.

DaniGP17 commented 1 month ago

This was already solved with the msgpack reverted