You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: new ArenaTopics() leaves every segment null, so topic segment access throws #192
and its constructor at :39-62 takes ten arguments that all default to "". That is not the parameterless constructor: new ArenaTopics() (and default(ArenaTopics)) zero-initializes the struct, so REALM, nameSpace, sceneName … (:63-72) come out null, not empty string. The default arguments are unreachable through that syntax.
The interpolated getters (:78-108) still produce well-shaped strings, because $"…" renders a null as empty — which is exactly what hides the problem. Any caller touching a segment directly gets a NullReferenceException from a value that looks default-constructed.
Observed
Runtime/ArenaTopics.cs compile-linked and run on .NET 8:
new ArenaTopics():
REALM==null: True, nameSpace==null: True, sceneName==null: True, idTag==null: True
new ArenaTopics().PUB_SCENE_OBJECTS => "/s///o//" (renders fine, hides the nulls)
new ArenaTopics().nameSpace.Length => System.NullReferenceException
new ArenaTopics().sceneName.StartsWith("x") => System.NullReferenceException
new ArenaTopics("").nameSpace.Length => 0 (the ctor path is fine)
So it is specifically the parameterless path that is unsafe; passing even one argument runs the constructor and the remaining defaults apply.
Fix options
coalesce in the property getters (get { return _nameSpace ?? ""; }), which fixes default(ArenaTopics) too — the only option that closes the hole completely for a struct;
make the type a class, so there is a real parameterless constructor to run;
or keep it as-is, add a static ArenaTopics.Empty built through the constructor, and document that new ArenaTopics() is not it.
#183 pins the current behaviour in Tests~/DotNet/ArenaUnity.PureTests/ArenaTopicsTests.cs with three Is.Null assertions; those flip if the coalescing option is chosen.
Activity