[Bug] .NET 10 NativeApi.PushArg<T> throws "Unsupported type String" when passed null, breaking AddStateBagChangeHandler wildcard bagName #423
unknown-urge
started this conversation in
[BUG] FiveM for GTAV Enhanced
Replies: 2 comments
|
Hey! This issue has been fixed in the latest patch b123 and CitizenFX.FiveM NuGets 0.0.4-alpha. Please try again and let us know if the issue persists. Additionally there's a new API for easier StateBag management: you can use |
0 replies
|
Since there is a new API, this issue can be closed. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
CitizenFX.Base.NativeApi.PushArg<T>(T arg)throwsSystem.Exception: Unsupported type Stringwhenever it is called withT = stringandarg == null, which makes it impossible to passnullfor any nullable/optional string native argument from C# resource code.The clearest manifestation is
ADD_STATE_BAG_CHANGE_HANDLER'sbagNameparameter, documented (and functional from Lua/JS) as "pass no value /nilto match every bag for the given key" (see the wildcard listener pattern in the migration guide). In C#,Native.AddStateBagChangeHandler(keyName, null, funcRef)cannot be used to reach this behavior at all — it throws immediately.In my testing this was not a contained, per-call failure: it crashed the entire client script host for the resource, with every other
IScriptin that resource then loggingScript not foundon subsequent events.Issue type
Client, Server (the affected type,
CitizenFX.Base.NativeApi, is shared by bothCitizenFX.FiveM.ClientandCitizenFX.FiveM.Server)Repro rate
Always
Server build version
No response
OS
Windows
CPU
No response
GPU
No response
RAM
No response
Storage type
No response
Connection type
No response
ISP and bandwidth
No response
DxDiag
No response
Network graph
No response
Platform
Windows
OS version / distribution
Windows 11
CPU
No response
RAM
No response
Using txAdmin?
No response
Hosting provider
No response
Machine type
No response
/perf endpoint output
No response
DDoS protection
No response
ulimit -n value (Linux only)
No response
Docker Compose file (Docker only)
No response
Steps to Reproduce
CitizenFX.FiveM.Client0.0.3-alpha (NuGet, nuget.org) from a client resource script.IScript.Initialize(), register a state bag change handler with anullbagName, mirroring the documented wildcard-listener pattern:Expected Behavior
The handler registers successfully and fires for any bag (not just one specific bag name) whenever
testKeychanges, matching the documented Lua/JS behavior for anil/omittedbagName.Actual Behavior
This is not specific to
AddStateBagChangeHandler— it is a bug inPushArg<T>'s own generic dispatch logic. Any native wrapper that callsPushArg<string>(null)for a nullable string parameter hits the same throw.Evidence
Additional Context
All reactions