Skip to content

[release/10.0] Fix ComInterfaceGenerator collision on same-named methods in disjoint cross-assembly bases#129473

Open
Copilot wants to merge 2 commits into
release/10.0from
copilot/fix-cominterfacegenerator-collision-again
Open

[release/10.0] Fix ComInterfaceGenerator collision on same-named methods in disjoint cross-assembly bases#129473
Copilot wants to merge 2 commits into
release/10.0from
copilot/fix-cominterfacegenerator-collision-again

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

main PR AaronRobinsonMSFT@55aa5e6

Addresses #122708 in .NET 10.

Description

Cross-assembly [GeneratedComInterface] inheritance could fail generation when disjoint external bases each exposed a same-named method (customer repro: MyMethod), producing CS8785 from a ComMethodInfo dictionary key collision. This PR ports the servicing-safe dedup fix for release/10.0 and adds targeted regression coverage.

Customer Impact

Without this fix, valid cross-assembly COM interface hierarchies fail to compile under source generation, blocking .NET 10 migration scenarios reported by enterprise customers.

Regression

No. This is a latent key-collision bug in external-interface handling, surfaced by specific same-name cross-assembly method shapes.

Testing

  • Reproduced pre-fix failure (CS8785 with duplicate ComMethodInfo key).
  • Added regression assets/tests for the customer shape (combined + standalone variants).
  • Ran ComInterfaceGenerator.Tests (with standard failing/ignore/outerloop exclusions); new tests and suite pass.

Risk

Low. Change is surgical and confined to generator-internal key identity for externally-defined methods; no public API, generated source contract, or runtime behavior changes.

Copilot AI and others added 2 commits June 16, 2026 17:09
Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

@AaronRobinsonMSFT AaronRobinsonMSFT added the Servicing-consider Issue for next servicing release review label Jun 16, 2026
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 10.0.x milestone Jun 16, 2026
@AaronRobinsonMSFT AaronRobinsonMSFT marked this pull request as ready for review June 16, 2026 19:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports a servicing-safe fix to the ComInterfaceGenerator for release/10.0 to prevent key collisions when collecting externally-defined COM interface methods that share the same name across disjoint base interfaces (cross-assembly inheritance scenario, issue #122708).

Changes:

  • Extend generator-internal ComMethodInfo identity for externally-defined methods with a stable per-symbol ExternalSymbolId (doc comment id / fully-qualified fallback) to avoid dictionary key collisions.
  • Add SharedTypes test assets that model two external base interfaces with same-named methods.
  • Add cross-assembly inheritance regression coverage validating combined and standalone implementations.
Show a summary per file
File Description
src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/BaseInterfaces/ISameNameMethodsDifferentAssembly.cs Adds external base interfaces with same-named MyMethod to reproduce the collision shape across assemblies.
src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Tests/Interfaces/IDerivedFromExternalSameName.cs Adds derived test interfaces that inherit the new external bases (with SYSLIB1230 suppressed, consistent with existing tests).
src/libraries/System.Runtime.InteropServices/tests/ComInterfaceGenerator.Tests/CrossAssemblyInheritanceTests.cs Adds regression tests covering both-disjoint-bases and standalone base-path behavior through StrategyBasedComWrappers.
src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/ComMethodInfo.cs Fixes external-method keying by incorporating ExternalSymbolId into record equality/hash for externally-defined methods.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

@JulieLeeMSFT JulieLeeMSFT added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants