Repository navigation
THRIFT-4833: Mark generated netstd properties that hide inherited members as new - #4103
Merged
Merged
Conversation
…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>
4 tasks done
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.
THRIFT-4833
A field named like a member of
System.Exception, such asmessageordata, 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 theSystem.ObjectmembersGetType,MemberwiseCloneandReferenceEquals.Changes
t_netstd_generator.cc,t_netstd_generator.h: such properties are now declarednew, which keeps today's behaviour. Through the generated type the property returns the field; throughExceptionorobjectthe inherited member is unchanged.Message,Data,Source,HelpLink,StackTrace.InnerException,HResult,TargetSite,GetBaseException,GetObjectData,SerializeObjectState.GetType,MemberwiseClone,ReferenceEquals.ToString,EqualsandGetHashCode. The generated classes declare these themselves, so such a field name is a compile error (CS0102) either way.Finalizecannot be hidden.Thrift.Compile.*projects treat CS0108, CS0109 and CS0114 as errors. CS0109 catches anewthat hides nothing. They also compile the newThrift4833.thrift, which uses all these names as fields of exceptions, a struct and a service.InheritedMemberNamestests read the field, and the inherited member through the base type.Verification
Thrift.Compileprojects 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.Xception.Messagereturns the field and((Exception)x).Messagethe base message, as before.Messagegainsnew.test/netstdbuilds without warnings.GetObjectDataandSerializeObjectStateare obsolete in .NET. If a later framework drops them, CS0109 will flag them inThrift4833.thrift.With this change, the net11 draft #3963 no longer needs CS0114 and CS0108 in
WarningsNotAsErrors.🤖 Generated with Claude Code