-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Runtime.InteropServicesin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is mergedsource-generatorIndicates an issue with a source generator featureIndicates an issue with a source generator feature
Milestone
Description
Description
Consider the following code:
[GeneratedComInterface, Guid("427CE02F-515A-4338-BE30-F70DA3ADAEC1")]
public unsafe partial interface IRoot
{
void MyMethod0();
}
[GeneratedComInterface, Guid("1AEE856E-6501-43C8-843B-8210B57DFD27")]
public unsafe partial interface ItfA : IRoot
{
void MyMethod1();
}
[GeneratedComInterface, Guid("3264857C-BB23-418D-9528-1E4226F2FEA4")]
public unsafe partial interface ItfB : IRoot
{
void MyMethod2();
}when IRoot is defined int the same assembly it works.
However when it is defined in another assembly, I get:
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.'.
Detailed msbuild output:
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.'.
1> System.ArgumentException: An item with the same key has already been added.
1> at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
1> at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
1> at Microsoft.Interop.ComInterfaceContext.GetContexts(ImmutableArray`1 data, CancellationToken _)
1> at Microsoft.CodeAnalysis.TransformNode`2.UpdateStateTable(Builder builder, NodeStateTable`1 previousTable, CancellationToken cancellationToken)
Debugging this shows:
Reproduction Steps
see above
Expected behavior
no exception raised
Actual behavior
see description the following exception is raised System.ArgumentException: An item with the same key has already been added.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
area-System.Runtime.InteropServicesin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is mergedsource-generatorIndicates an issue with a source generator featureIndicates an issue with a source generator feature
Type
Projects
Status
No status
