Skip to content

THRIFT-4833: Mark generated netstd properties that hide inherited members as new - #4103

Merged
Jens-G merged 1 commit into
apache:masterfrom
Jens-G:THRIFT-4833
Nov 6, 2026
Merged

Jens-G merged 1 commit into
apache:masterfrom
Jens-G:THRIFT-4833

Conversation

@Jens-G

@Jens-G Jens-G commented Nov 4, 2026

Copy link
Copy Markdown
Member

THRIFT-4833

A field named like a member of System.Exception, such as message or data, became a property that hides that member. The compiler warned with CS0114, 'Xception.Message' hides inherited member 'Exception.Message', or with CS0108. The same happened in every generated class for fields named like the System.Object members GetType, MemberwiseClone and ReferenceEquals.

Changes

  • t_netstd_generator.cc, t_netstd_generator.h: such properties are now declared new, which keeps today's behaviour. Through the generated type the property returns the field; through Exception or object the inherited member is unchanged.
    • Exceptions, CS0114: Message, Data, Source, HelpLink, StackTrace.
    • Exceptions, CS0108: InnerException, HResult, TargetSite, GetBaseException, GetObjectData, SerializeObjectState.
    • Every generated class, CS0108: GetType, MemberwiseClone, ReferenceEquals.
    • Left out are ToString, Equals and GetHashCode. The generated classes declare these themselves, so such a field name is a compile error (CS0102) either way. Finalize cannot be hidden.
  • The four Thrift.Compile.* projects treat CS0108, CS0109 and CS0114 as errors. CS0109 catches a new that hides nothing. They also compile the new Thrift4833.thrift, which uses all these names as fields of exceptions, a struct and a service.
  • InheritedMemberNames tests read the field, and the inherited member through the base type.

Verification

  • With the master compiler, the four Thrift.Compile projects fail to build with these settings: 172 errors, 43 per project, e.g. ThriftTest/Xception.cs(63,20): error CS0114: 'Xception.Message' hides inherited member 'Exception.Message'. With the fix they build without a warning or an error.
  • The new runtime tests pass with the code from both compilers. Xception.Message returns the field and ((Exception)x).Message the base message, as before.
  • Over the test IDLs, 5 generated files change, each because an exception's Message gains new.
  • Thrift.Tests passes 156 of 156, IntegrationTests 57 of 57, and the compiler tests pass. test/netstd builds without warnings.

GetObjectData and SerializeObjectState are obsolete in .NET. If a later framework drops them, CS0109 will flag them in Thrift4833.thrift.

With this change, the net11 draft #3963 no longer needs CS0114 and CS0108 in WarningsNotAsErrors.

🤖 Generated with Claude Code

…bers as new

Client: netstd

A field named like a member of System.Exception, such as message or data, became a
property that hides that member, with warning CS0114 or CS0108. Such properties,
and those named like a member of System.Object, are now declared new. The
Thrift.Compile projects treat CS0108, CS0109 and CS0114 as errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mergeable mergeable Bot added c# Pull requests that update C# code Pull requests that update .NET code compiler labels Nov 4, 2026
@Jens-G
Jens-G merged commit 628dbd1 into apache:master Nov 6, 2026
89 checks passed
@Jens-G
Jens-G deleted the THRIFT-4833 branch November 6, 2026 21:24
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 Pull requests that update .NET code compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant