Skip to content

THRIFT-5997 THRIFT-5998: Fix netstd generator const and duplicate extension method bugs#3477

Merged
Jens-G merged 2 commits into
apache:masterfrom
Jens-G:THRIFT-5997-5998-netsdt-codegen
May 14, 2026
Merged

THRIFT-5997 THRIFT-5998: Fix netstd generator const and duplicate extension method bugs#3477
Jens-G merged 2 commits into
apache:masterfrom
Jens-G:THRIFT-5997-5998-netsdt-codegen

Conversation

@Jens-G
Copy link
Copy Markdown
Member

@Jens-G Jens-G commented May 14, 2026

Summary

Two netstd code-generator bugs found and fixed during a codegen test run
against all 201 Thrift IDL files in the repository (603 test executions
across net8/net9/net10 — all passing after these fixes).

THRIFT-5997binary and uuid consts must use static readonly

C# does not permit const for byte[] (Thrift binary) or System.Guid
(Thrift uuid). The generator unconditionally emitted public const for
all base types, producing CS0283/CS0134 compile errors for any IDL file
containing a const binary or const uuid field.

Fix: check the base type before emitting const; fall back to
public static readonly (or public static on older targets).

THRIFT-5998 — duplicate extension methods from included programs (CS0121)

When a Thrift IDL file included another, collect_extensions_types()
recursed into structs from the included program. This caused the same
container extension methods (DeepCopy, Equals, GetHashCode) to be
emitted in both the including and the included file's *Extensions.cs,
producing CS0121 "ambiguous call" errors at C# compile time.

Fix: stop recursion at the program boundary. Each program's generator
only walks its own structs; the included program's generator handles its
own internal container types.

Test plan

  • Verified on Linux with separate test script (not part of the PR)

🤖 Generated with Claude Code

Jens-G and others added 2 commits May 14, 2026 21:57
…atic readonly

Client: netstd

C# does not allow `const` for byte[] or Guid types. The generator
unconditionally emitted `public const` for all base types, causing
CS0283/CS0134 compile errors for Thrift fields of type binary or uuid.

Also improves the netstd codegen test script: fix cross-platform paths,
detect cmake-built thrift compiler, expand NET_VERSIONS to net8/9/10,
and reduce KNOWN_BUGS/FAIL_THRIFT to accurately reflect current state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ncluded programs

Client: netstd

When a Thrift IDL file included another, collect_extensions_types()
recursed into structs from the included program, causing the same
container extension methods (DeepCopy, Equals, GetHashCode) to be
emitted in both files. This produced CS0121 "ambiguous call" errors at
C# compile time.

Fix: stop recursion at program boundary. Each program's generator only
walks its own structs; the included program's generator handles theirs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mergeable mergeable Bot added the compiler label May 14, 2026
@Jens-G Jens-G added the c# Pull requests that update C# code label May 14, 2026
@Jens-G Jens-G self-assigned this May 14, 2026
@Jens-G Jens-G changed the title THRIFT-5997/5998: Fix netstd generator const and duplicate extension method bugs THRIFT-5997 THRIFT-5998: Fix netstd generator const and duplicate extension method bugs May 14, 2026
@Jens-G Jens-G merged commit 85374a0 into apache:master May 14, 2026
172 of 174 checks passed
@Jens-G Jens-G deleted the THRIFT-5997-5998-netsdt-codegen branch May 21, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c# Pull requests that update C# code compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant