Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComWrappers source generator fails to run: CSC : warning CS8785: Generator 'ComInterfaceGenerator' failed to generate source #111573

Open
smourier opened this issue Jan 18, 2025 · 1 comment
Labels
area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature untriaged New issue has not been triaged by the area owner

Comments

@smourier
Copy link

smourier commented Jan 18, 2025

Description

I'm compiling a class library project with Visual Studio 2022 .NET 9 and when I compile, it raises a CSC 8785 warning and the description of exception: Exception was of type 'ArgumentException' with message 'An item with the same key has already been added.'.

Reproduction Steps

Unfortunately, I can't provide a reproducing project this is a private project that defines around 500 COM interfaces like this:

[GeneratedComInterface, Guid("1f9fc1d0-c39b-4b26-817f-011967d3440e")]
public partial interface IPropertyDescriptionList
{
    ....
}

And the csproj is defined like this:

<PropertyGroup>
	<TargetFramework>net9.0</TargetFramework>
	<Nullable>enable</Nullable>
	<IsAotCompatible>true</IsAotCompatible>
	<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
	<PublishAot>true</PublishAot>
	<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

I've tried to reproduce on a small project but it never fail, it works and I have similar projects that compile fine. It seems the ComInterfaceGenerator doesn't like something specific, but I can't find what it is

Expected behavior

I believe the 'ComInterfaceGenerator' should not fail with unexpected/internal errors like ArgumentException only with a predefined set of diagnostics

Actual behavior

This is Visual Studio CSC outputs:

1>------ Rebuild All started: Project: ShellN, Configuration: Release Any CPU ------
Restored E:\smo\GitHub\ShellN\ShellN\ShellN.csproj (in 14 ms).
1>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>ShellN -> E:\smo\GitHub\ShellN\ShellN\bin\Release\net9.0\ShellN.dll
1>Done building project "ShellN.csproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 19:08 and took 03,168 seconds ==========

Regression?

I don't know, I've not tested .NET 8

Known Workarounds

I don't have any

Configuration

Visual Studio 2022 17.12.4
.NET 9.0.1
Windows 11 24H2 x64 26100.2894

Other information

Is there a way to enable some logs or diagnostics so I could at least see where/how it's failing?

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 18, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 18, 2025
@smourier smourier changed the title ComWrappers source generators fails to run: CSC : warning CS8785: Generator 'ComInterfaceGenerator' failed to generate source ComWrappers source generator fails to run: CSC : warning CS8785: Generator 'ComInterfaceGenerator' failed to generate source Jan 18, 2025
@teo-tsirpanis teo-tsirpanis added area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 18, 2025
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature untriaged New issue has not been triaged by the area owner
Projects
Status: No status
Development

No branches or pull requests

2 participants