dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.96k stars 4.02k forks source link

Can't diagnose analyzer error related to generated file. #50166

Open CyrusNajmabadi opened 3 years ago

CyrusNajmabadi commented 3 years ago

Running build.cmd -a on roslyn, i get:

C:\github\roslyn\src\Compilers\CSharp\Portable\CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Main.Generated.cs(4565,44): error RS0016: Symbol 'UsingDirective' is not part of the declared API [C:\github\roslyn\sr
c\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj]
C:\github\roslyn\src\Compilers\CSharp\Portable\CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Main.Generated.cs(4574,44): error RS0016: Symbol 'UsingDirective' is not part of the declared API [C:\github\roslyn\sr
c\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj]
C:\github\roslyn\src\Compilers\CSharp\Portable\CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Main.Generated.cs(4578,44): error RS0016: Symbol 'UsingDirective' is not part of the declared API [C:\github\roslyn\sr
c\Compilers\CSharp\Portable\Microsoft.CodeAnalysis.CSharp.csproj]

However, when i go to try to open those files to look at those lines so i can see what is being complained about, i don't see those files on disk at the path the error message specifies. So i can't figure out what's gone wrong or how to fix it.

sharwell commented 3 years ago

The file is here: https://github.com/dotnet/roslyn/blob/246b8274deeb44885337bb0543357fdc0c165203/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs

Looks like the /Generated path segment was left out from the error.

sharwell commented 3 years ago

@chsienki It seems like the compiler error messages should point to the file created on disk for cases where the build is set to write generated files.

jasonmalinowski commented 3 years ago

Indeed, moving to @chsienki to address.