-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Deduplicate base interfaces from another assembly in COM generator #111931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deduplicate base interfaces from another assembly in COM generator #111931
Conversation
src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceInfo.cs
Outdated
Show resolved
Hide resolved
...ystem.Runtime.InteropServices/tests/ComInterfaceGenerator.Unit.Tests/TargetSignatureTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceGenerator.cs
Outdated
Show resolved
Hide resolved
...es/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComInterfaceAndMethodsContext.cs
Outdated
Show resolved
Hide resolved
...es/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/TypePositionInfo.cs
Outdated
Show resolved
Hide resolved
…enerator/ComInterfaceAndMethodsContext.cs Co-authored-by: Aaron Robinson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes cross-assembly interface inheritance in the COM interface generator by properly handling external interface references and enabling deduplication of base interfaces from other assemblies. The key changes include refactoring the generation context hierarchy, moving shared interfaces to a common location, and adding comprehensive tests for cross-assembly inheritance scenarios.
Key changes:
- Adds deduplication of external
ComInterfaceInfo
s to prevent duplicate processing of base interfaces - Creates new context classes to separate source-available from sourceless method generation
- Moves shared COM interfaces from TestAssets/SharedTypes to Common folder for better organization
Reviewed Changes
Copilot reviewed 25 out of 72 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
SharedTypes.csproj | Removes code generation exclusion to enable proper interface inheritance testing |
IExternalBase.cs / IExternalDerived.cs | Adds base COM interfaces for cross-assembly inheritance testing |
CrossAssemblyInheritanceTests.cs | Comprehensive test suite validating VTable layout consistency across assemblies |
ComInterfaceGenerator.cs | Implements external interface deduplication and refactors stub generation logic |
IncrementalMethodStubGenerationContext.cs | Creates inheritance hierarchy for source-available vs. sourceless contexts |
ComInterfaceInfo.cs | Adds equality comparer for external interface deduplication |
Fixes cross-assembly interface inheritance.
Deduplicate external
ComInterfaceInfo
s in the pipeline.Don't remove external interface methods in the generator pipeline - these are required to create the new VTable struct type introduced in #116289.
Creates a new SourceAvailableIncrementalMethodStubGenerationContext for methods with source available and use IncrementalMethodStubGenerationContext as a base for externally defined methods.
Moves the ComInterfaces from SharedTypes to the Common folder, and defines a limited set of base interfaces in SharedTypes for interfaces in ComInterfaceGenerator to derived from. Adds a number of tests for different levels of inheritance across assemblies.