Skip to content

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

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

[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.

  • Keying fix (generator-internal only)
    • Add ExternalSymbolId to ComMethodInfo so externally-defined methods (Syntax == null) have stable per-symbol identity in record equality/hash.
    • Populate at the external-method construction site using GetDocumentationCommentId() with fully-qualified fallback.
  • Regression tests
    • Add external shared interfaces with same-name methods and customer GUIDs.
    • Add two derived test interfaces in ComInterfaceGenerator.Tests.
    • Add three facts covering:
      • combined implementation of both disjoint bases
      • standalone implementation for each base path.
private static string BuildExternalSymbolId(IMethodSymbol method)
    => method.GetDocumentationCommentId()
        ?? method.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);

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 (Synopsys).

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Runtime.InteropServices Servicing-consider Issue for next servicing release review

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants