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

AD0001: 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' during publish #5917

Closed
credfeto opened this issue Mar 13, 2022 · 2 comments
Closed

Comments

@credfeto
Copy link

credfeto commented Mar 13, 2022

Analyzer

AD0001 crash in ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer in 6.0.200 / 6.0.201

Run dotnet publish --no-restore -warnaserror -p:PublishSingleFile=true --configuration:Release -r:linux-x64 --self-contained:true -p:PublishReadyToRun=False -p:PublishReadyToRunShowWarnings=True -p:PublishTrimmed=False -p:DisableSwagger=False -p:TreatWarningsAsErrors=True -p:Version=0.0.1.9-master -p:IncludeNativeLibrariesForSelfExtract=false -p:SolutionDir=..\\ --output ../server-dist
Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  AD0001.Publish.Example.Lib1.Data.Interfaces -> /home/runner/work/roslyn-ad0001-requiresassemblyfilesanalyzer-error/roslyn-ad0001-requiresassemblyfilesanalyzer-error/src/AD0001.Publish.Example.Lib1.Data.Interfaces/bin/Release/net6.0/AD0001.Publish.Example.Lib1.Data.Interfaces.dll
  AD0001.Publish.Example.Database.Interfaces -> /home/runner/work/roslyn-ad0001-requiresassemblyfilesanalyzer-error/roslyn-ad0001-requiresassemblyfilesanalyzer-error/src/AD0001.Publish.Example.Database.Interfaces/bin/Release/net6.0/AD0001.Publish.Example.Database.Interfaces.dll
  AD0001.Publish.Example.Lib1 -> /home/runner/work/roslyn-ad0001-requiresassemblyfilesanalyzer-error/roslyn-ad0001-requiresassemblyfilesanalyzer-error/src/AD0001.Publish.Example.Lib1/bin/Release/net6.0/AD0001.Publish.Example.Lib1.dll
CSC : error AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.TypeParameterSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'.'. [/home/runner/work/roslyn-ad0001-requiresassemblyfilesanalyzer-error/roslyn-ad0001-requiresassemblyfilesanalyzer-error/src/AD0001.Publish.Example.Database.Dapper/AD0001.Publish.Example.Database.Dapper.csproj]
Error: Process completed with exit code 1.

Analyzer source

SDK: Built-in CA analyzers in .NET 6 SDK or later(https://docs.microsoft.com/dotnet/fundamentals/productivity/code-analysis)

Version: SDK 6.0.201, 6.0.200

Note issue doesn't appear in 6.0.102, 6.0.103...

Also happens when the Microsoft.CodeAnalysis.NetAnalyzers 6.0.0 package directly with the 6.0.201, 6.0.200 SDKS but not with 6.0.102, 6.0.103

NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers

Version: 6.0.0

Describe the bug

When publishing using the following command line Get an AD0001 error.

Steps To Reproduce

  1. Clone https://github.com/credfeto/roslyn-ad0001-requiresassemblyfilesanalyzer-error
  2. Checkout to branch depends/ff-3881/update-dotnet/6.0.201/src/global.json
  3. In bash go to src
  4. run dotnet publish --no-restore -warnaserror -p:PublishSingleFile=true --configuration:Release -r:linux-x64 --self-contained:true -p:PublishReadyToRun=False -p:PublishReadyToRunShowWarnings=True -p:PublishTrimmed=False -p:DisableSwagger=False -p:TreatWarningsAsErrors=True -p:Version=0.0.1.149-master -p:IncludeNativeLibrariesForSelfExtract=false -p:SolutionDir=..\\ --output ../publish
  5. See errors in output:
CSC : error AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.TypeParameterSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'.'. [/home/markr/work/personal/roslyn-ad0001-requiresassemblyfilesanalyzer-error/src/AD0001.Publish.Example.Database.Dapper/AD0001.Publish.Example.Database.Dapper.csproj]

note that if you change the .net SDK version to 6.0.102 (as is in master) then the error can no longer be reproduced.

Expected behavior

Compiles with no AD0001 error (or a sane diagnostic to be output that can be fixed)

Actual behavior

CSC : error AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.TypeParameterSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'.'. [/home/markr/work/personal/roslyn-ad0001-requiresassemblyfilesanalyzer-error/src/AD0001.Publish.Example.Database.Dapper/AD0001.Publish.Example.Database.Dapper.csproj]

Additional context

Example code that demonstrates the issue showing the one change needed to exhibit it:

credfeto/credfeto-notification-bot#10

@credfeto credfeto changed the title error AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.TypeParameterSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'. error AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' during publish Mar 13, 2022
@credfeto credfeto changed the title error AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' during publish AD0001: 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' during publish Mar 13, 2022
@mavasani
Copy link
Contributor

@agocke

@Youssef1313
Copy link
Member

Duplicate of dotnet/linker#2642

@Youssef1313 Youssef1313 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants