You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ComInterfaceGenerator failed to generate source when two base COM interfaces in another assembly have methods of the same name #122708
Consider the following case, where two COM interfaces of one assembly each inherit one of the two disjoint base COM interfaces of another assembly. The two base interfaces happen have methods of the same name.
Compile Assembly2, and ComInterfaceGenerator fails to generate source.
Reproduction Steps
See Description.
Expected behavior
The code should compile with ComInterfaceGenerator generating source for COM interop.
Actual behavior
Compiling Assembly2 yields the following warning
CSC : warning CS8785: Generator 'ComInterfaceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'An item with the same key has already been added. Key: ComMethodInfo { Syntax = , MethodName = MyMethod, Attributes = SequenceEqualImmutableArray { Array = System.Collections.Immutable.ImmutableArray`1[Microsoft.Interop.AttributeInfo], Comparer = System.Collections.Generic.GenericEqualityComparer`1[Microsoft.Interop.AttributeInfo], Length = 0 }, IsUserDefinedShadowingMethod = False }'.
indicating that ComInterfaceGenerator has failed to generate source for COM interop.
This is also true even if you put IInterface1 and IInterface2 into two different namespaces.
Regression?
Not sure, but should affect .NET 9 also.
Known Workarounds
Putting IInterface1 and IInterface2 in two separate assemblies.
in the repro shared by @LideLinusZhang, if one of Interface3.cs or Interface4.cs is omitted, the projects build. If both are built an exception is thrown.
Activity
dotnet-policy-service commentedon Dec 22, 2025
Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.
LideLinusZhang commentedon Mar 9, 2026
Reproduction Solution: ComBugReproduction.zip
m-celikba commentedon Mar 9, 2026
in the repro shared by @LideLinusZhang, if one of Interface3.cs or Interface4.cs is omitted, the projects build. If both are built an exception is thrown.
@AaronRobinsonMSFT this is a variation of 111890. Can someone please take a look ?
dotnet-policy-service commentedon Apr 13, 2026
Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.
Use GetDocumentationCommentId for external ComMethodInfo dedup
dotnet-policy-service commentedon Jun 15, 2026
Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.
Add support for properties in COM source generator (dotnet#128869)
[release/10.0] Fix ComInterfaceGenerator collision on same-named meth…
Add support for properties in COM source generator (#128869)
Add support for properties in COM source generator (dotnet#128869)