Make constructors private for parts of the ComInterfaceGenerator that should only be created from their static methods#101740
Merged
jtschuster merged 11 commits intodotnet:mainfrom May 29, 2024
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
Member
|
Personally, I do prefer using records here as the constraints around record usage (and the I also see changing to manual equality as a bug farm. We introduced a few bugs in LibraryImport when we had a few custom equality implementations because we forgot to update them. I think if we want to limit the constructor scope, we can manually define the record properties and define the more-scoped constructor in the body of the record, and just not use the "primary constructor" feature of records (while still getting the rest of the features of records). |
This was referenced May 1, 2024
…huster/runtime into ComGenUseClassesForPipeline
jkoritzinsky
approved these changes
May 28, 2024
…seClassesForPipeline
Ruihan-Yin
pushed a commit
to Ruihan-Yin/runtime
that referenced
this pull request
May 30, 2024
… should only be created from their static methods (dotnet#101740) Moves ComClassInfo to its own file and moves the Func that produces them in the ComClassGenerator pipeline to a static method on ComClassInfo. Makes the constructors for ComClassInfo, ComInterfaceContext, ComInterfaceInfo, and `ComMethoInfo private to enforce that they are only created from the static creation methods. Creates more static SpecialTypeInfo types for sbyte, uint, short, and ushort. Changes pattern matching on records to use property pattern matching rather than the deconstruction notation for records. Since the constructors are not accessible, neither are the deconstruct methods.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Part of #101615
Moves
ComClassInfoto its own file and moves the Func that produces them in theComClassGeneratorpipeline to a static method onComClassInfo.Makes the constructors for
ComClassInfo,ComInterfaceContext,ComInterfaceInfo, and `ComMethoInfo private to enforce that they are only created from the static creation methods.Creates more static SpecialTypeInfo types for
sbyte,uint,short, andushort.Changes pattern matching on records to use property pattern matching rather than the deconstruction notation for records. Since the constructors are not accessible, neither are the deconstruct methods.