Skip to content

fix C# and Go identifier and member name collisions - #1761

Merged
alexcrichton merged 2 commits into
bytecodealliance:mainfrom
Snowiiii:fix/csharp-duplicate-definitions
Oct 30, 2026
Merged

alexcrichton merged 2 commits into
bytecodealliance:mainfrom
Snowiiii:fix/csharp-duplicate-definitions

Conversation

@Snowiiii

Copy link
Copy Markdown
Contributor

Fixes duplicate definitions and member name collisions in C# (and Go) bindings generation (#1731, #1641, #1703, #1515):

  • Disambiguate variant Tag field, Tags nested class, Tags.<Case> constants, As<Case> payload accessors, and static factory methods when variant names or case names collide.
  • Disambiguate resource Handle property, THandle struct, WasmInterop nested class, Dispose implementation, and resource method/static function names when resource or method names collide.
  • Qualify global::System.GC.SuppressFinalize(this) in exported resources.
  • Allocate cleanups, cleanup, and async result locals via Ns so they do not shadow function parameters.
  • Convert WIT identifiers to camelCase before checking against C# keywords in to_csharp_ident / to_csharp_ident_upper.
  • Repeat */ sanitization in print_docs to handle nested comment closures like **/.
  • Use the mangled payload getter name (<Case>_()) when lowering variants in Go if the case name collides with a reserved variant method.

Fixes duplicate definitions and member name collisions in C# (and Go)
bindings generation (bytecodealliance#1731, bytecodealliance#1641, bytecodealliance#1703, bytecodealliance#1515):

- Disambiguate variant `Tag` field, `Tags` nested class, `Tags.<Case>`
  constants, `As<Case>` payload accessors, and static factory methods when
  variant names or case names collide.
- Disambiguate resource `Handle` property, `THandle` struct, `WasmInterop`
  nested class, `Dispose` implementation, and resource method/static
  function names when resource or method names collide.
- Qualify `global::System.GC.SuppressFinalize(this)` in exported resources.
- Allocate `cleanups`, `cleanup`, and async `result` locals via `Ns` so
  they do not shadow function parameters.
- Convert WIT identifiers to camelCase before checking against C# keywords
  in `to_csharp_ident` / `to_csharp_ident_upper`.
- Repeat `*/` sanitization in `print_docs` to handle nested comment
  closures like `**/`.
- Use the mangled payload getter name (`<Case>_()`) when lowering variants
  in Go if the case name collides with a reserved variant method.
@alexcrichton
alexcrichton added this pull request to the merge queue Oct 30, 2026
Merged via the queue into bytecodealliance:main with commit f4548f7 Oct 30, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants