dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.07k forks source link

GenAPI fails to generate source for latest Corelib #40090

Open ericstj opened 7 months ago

ericstj commented 7 months ago

Describe the bug

GenAPI fails when generating source for the latest CoreLib:

Unhandled exception: System.ArgumentException: Unknown operator kind. (Parameter 'System.Half.explicit operator checked byte(System.Half)')
   at Microsoft.DotNet.GenAPI.SyntaxGeneratorExtensions.DeclarationExt(SyntaxGenerator syntaxGenerator, ISymbol symbol, ISymbolFilter symbolFilter) in /_/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/SyntaxGeneratorExtensions.cs:line 107
   at Microsoft.DotNet.GenAPI.CSharpFileBuilder.Visit(SyntaxNode namedTypeNode, INamedTypeSymbol namedType) in /_/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/CSharpFileBuilder.cs:line 211
   at Microsoft.DotNet.GenAPI.CSharpFileBuilder.Visit(INamespaceSymbol namespaceSymbol) in /_/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/CSharpFileBuilder.cs:line 118
   at Microsoft.DotNet.GenAPI.CSharpFileBuilder.WriteAssembly(IAssemblySymbol assemblySymbol) in /_/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/CSharpFileBuilder.cs:line 72
   at Microsoft.DotNet.GenAPI.GenAPIApp.Run(ILog logger, String[] assemblies, String[] assemblyReferences, String outputPath, String headerFile, String exceptionMessage, String[] excludeApiFiles, String[] excludeAttributesFiles, Boolean respectInternals, Boolean includeAssemblyAttributes) in /_/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/GenAPIApp.cs:line 86
   at Microsoft.DotNet.GenAPI.Tool.Program.<>c__DisplayClass0_0.<Main>b__0(ParseResult parseResult) in /_/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI.Tool/Program.cs:line 100
   at System.CommandLine.CliCommand.<>c__DisplayClass30_0.<SetAction>b__0(ParseResult context)
   at System.CommandLine.Invocation.AnonymousSynchronousCliAction.Invoke(ParseResult parseResult)
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)

To Reproduce

dotnet tool install -g microsoft.dotnet.genapi.tool --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9-transport/nuget/v3/index.json --prerelease
genapi --assembly C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.4\System.Private.CoreLib.dll --output-path c:\scratch\spc\spc.cs

Exceptions (if any)

System.ArgumentException: Unknown operator kind
ericstj commented 7 months ago

Same thing repros for System.Runtime.

Appears to be this bug: https://github.com/dotnet/roslyn/issues/63410

ViktorHofer commented 6 months ago

Given that this got fixed recently in roslyn, we should rerun the above repro steps with the latest available GenAPI tooling.

ViktorHofer commented 6 months ago

Interestingly this still repros with the latest GenAPI that bundles roslyn assemblies from this SHA: https://github.com/dotnet/roslyn/commit/84c5476ef3111c9abd78d43e65063280bb7202d9

Same stack trace