THRIFT-5997 THRIFT-5998: Fix netstd generator const and duplicate extension method bugs#3477
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-5997 —
binaryanduuidconsts must usestatic readonlyC# does not permit
constforbyte[](Thriftbinary) orSystem.Guid(Thrift
uuid). The generator unconditionally emittedpublic constforall base types, producing CS0283/CS0134 compile errors for any IDL file
containing a
const binaryorconst uuidfield.Fix: check the base type before emitting
const; fall back topublic static readonly(orpublic staticon 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 beemitted 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
🤖 Generated with Claude Code