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: Analyzer 'ILLink.RoslynAnalyzer.RequiresUnreferencedCodeAnalyzer' threw an exception of type 'System.InvalidCastException' #2642

Closed
Sergio0694 opened this issue Feb 22, 2022 · 11 comments
Milestone

Comments

@Sergio0694
Copy link

Analyzer

Diagnostic ID: AD0001.

Analyzer source

SDK: .NET 6.0.2 SDK, using VS 17.1

Describe the bug

Building a solution after updating to VS17.1 causes the following issue:

"CSC : error AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresUnreferencedCodeAnalyzer' 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'.'."

This used to work fine on VS 17.0 up to until a few days ago. Our CI also started failing as soon as the image was updated.

https://github.com/CommunityToolkit/dotnet/pull/121/checks?check_run_id=5287917761

Steps To Reproduce

  1. Checkout to Fix analyzer build warnings/errors CommunityToolkit/dotnet#121 (CommunityToolkit/dotnet@71ad82d)
  2. Build the solution

Expected behavior

Should build fine.

Actual behavior

There is a build warning with the message mentioned above.

@mavasani
Copy link

@agocke is this analyzer owned by your team?

@agocke agocke transferred this issue from dotnet/roslyn-analyzers Feb 22, 2022
@marek-safar
Copy link
Contributor

marek-safar commented Feb 22, 2022

Seems like another servicing regression?

@marek-safar marek-safar added this to the .NET 6.0.x milestone Feb 22, 2022
@agocke
Copy link
Member

agocke commented Feb 22, 2022

17.1 brings in 6.0.2xx, so this might be from changes in there. @sbomer does this look familiar?

@sbomer
Copy link
Member

sbomer commented Feb 22, 2022

This looks like the crash you fixed in 42c199a (that seems to be the only place with a suspicious cast to INamedTypeSymbol in 6.0.2xx). Should we take that part of the fix into a servicing branch?

@agocke
Copy link
Member

agocke commented Feb 22, 2022

Confirmed the problem, this was fixed in my bootstrap PR, but wasn't backported to 6.0.2xx https://github.com/dotnet/linker/pull/2540/files

@agocke
Copy link
Member

agocke commented Feb 22, 2022

Yeah, we should bring that fix to the servicing branch.

@sbomer
Copy link
Member

sbomer commented Feb 24, 2022

Already fixed in main, and #2643 fixes this in 6.0.2.

@sbomer sbomer closed this as completed Feb 24, 2022
@nagya
Copy link

nagya commented Mar 11, 2022

Already fixed in main, and #2643 fixes this in 6.0.2.

@sbomer, a duplicate of this continues to repro in 6.0.201.

@sbomer
Copy link
Member

sbomer commented Mar 14, 2022

Sorry @nagya, it looks like the fix wasn't made in time for that patch release. Currently it's waiting on dependency flow from dotnet/sdk into dotnet/installer: dotnet/installer#13394. Thank you for following up on this.

@RealDotNetDave
Copy link

I am having the same issue. When will this be fixed since I can't compile my assembly??

@agocke
Copy link
Member

agocke commented Mar 21, 2022

Patch releases for .NET are every patch Tuesday, so our next update is April 12th. However, this should already be fixed in preview, so if you install the .NET 7 preview release, you should see the fix.

Alternatively, you can temporarily disable trim warnings by setting <EnableTrimAnalyzer>false</EnableTrimAnalyzer>

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

7 participants