-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area-System.Runtime.InteropServicesuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Description
Description
Consider the following case, where two COM interfaces of one assembly each inherit one of the two base COM interfaces of another assembly. The two base interfaces have a method of the same name.
In Assembly1
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
namespace Assembly1
{
[GeneratedComInterface]
[Guid("2d3b434a-9119-45c6-9f40-1d35bb38d494")]
public partial interface IInterface1
{
double MyMethod();
}
[GeneratedComInterface]
[Guid("5ef8dd8a-6c27-4724-8645-4406a4e45a8d")]
public partial interface IInterface2
{
int MyMethod();
}
}And in Assembly2
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
namespace Assembly2
{
[GeneratedComInterface]
[Guid("b7c27add-cbc3-41c6-9e15-ddaf167c21a9")]
public partial interface IInterface3 : Assembly1.IInterface1;
[GeneratedComInterface]
[Guid("5193a610-67dd-46b4-9f8c-238047c97ffb")]
public partial interface IInterface4 : Assembly1.IInterface2;
}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
N/A
Configuration
- .NET Version: 10.0.101
- OS: Windows 11 Enterprise 24H2 Build 26100.7171
- Architecture: x64
Other information
May be related to #111890
Metadata
Metadata
Assignees
Labels
area-System.Runtime.InteropServicesuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
Type
Projects
Status
No status