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
C#: fields and functions in a NamespaceDeclaration are written directly into the namespace, so the output fails with CS0116 (CS0106 at file scope) #155
Building this gives error CS0116: A namespace cannot directly contain members such as fields, methods or statements. Putting the same members directly in a SourceFile, with no namespace, gives error CS0106: The modifier 'public' is not valid for this item instead.
The repo's own reflection-table exemplar has this shape. ExemplarReflectionTableTests.CSharp_WritesAnObjectInitialiserAndAStaticReadonlyField asserts static readonly for a FieldDeclaration inside NamespaceDeclaration("holo::components::reflection"), so the C# output that test pins does not compile (L62, L147-L153). C# has no compile test, unlike C, C++, Rust and Go, which is why this went unnoticed.
Suggested fix
Collect a namespace's (and a file's) non-type members into a generated public static class, and mark them static. Non-type members are FieldDeclaration, FunctionDeclaration and VariableDeclaration.
Name the class after the namespace's last segment, or use a fixed name such as Globals. Any naming convention works as long as the output compiles.
Leave types, enums, aliases and nested namespaces where they are.
Acceptance criteria
C# output for a namespace containing a constant table and a free function compiles.
Add a CSharpGeneratedSourceCompilesTests, matching the C/C++/Rust/Go ones, that builds the compiled exemplar with Roslyn or dotnet build.
Priority: Medium. C# output for any namespace (or file) that holds fields or free functions does not compile, and ExemplarReflectionTableTests currently pins that output. The failure is loud (CS0116/CS0106), not silent, and the fix stays inside CSharpGenerator.
Area:CSharpGenerator.GenerateNamespace / GenerateField / GenerateFunction, plus a new CSharpGeneratedSourceCompilesTests harness. Suggested owner: @matt-edmondson, C# generator
Activity
matt-edmondson commentedon Oct 5, 2026
Triage
ExemplarReflectionTableTestscurrently pins that output. The failure is loud (CS0116/CS0106), not silent, and the fix stays insideCSharpGenerator.CSharpGenerator.GenerateNamespace/GenerateField/GenerateFunction, plus a newCSharpGeneratedSourceCompilesTestsharness. Suggested owner: @matt-edmondson, C# generatorconst, which fails to compile with CS0133 #110 (C#constlocal with a non-literal initialiser). Adding the C# compile test will likely surface other C# gaps, so it is worth doing first.Generated by Claude Code