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.DynamicallyAccessedMembersAnalyzer' threw an exception of type 'System.InvalidCastException' #3106

Closed
MackinnonBuck opened this issue Nov 9, 2022 · 5 comments

Comments

@MackinnonBuck
Copy link
Member

Describe the bug

Annotating a parameter on a local function with [DynamicallyAccessedMembers] causes ILLink.RoslynAnalyzer.DynamicallyAccessedMembersAnalyzer to throw the following exception:

CSC : error AD0001: Analyzer 'ILLink.RoslynAnalyzer.DynamicallyAccessedMembersAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.MethodSymbol' to type 'Microsoft.CodeAnalysis.ITypeSymbol'.'.

This was observed in dotnet/aspnetcore#44925. The culprit was this line.

SDK version with the bug:
8.0.100-alpha.1.22556.1

Last known SDK version without the bug:
8.0.100-alpha.1.22531.1

Steps to reproduce

  1. Checkout https://github.com/dotnet/aspnetcore/tree/98bd1e8085ba090a352ed1eda7f86fd2bd5381ea
  2. Build the solution following these steps

Expected behavior

The build completes successfully.

Actual behavior

The build fails with the aforementioned error.

@sbomer
Copy link
Member

sbomer commented Nov 9, 2022

Corresponds to this commit range: 4db6ac9...391ac60.

I think this cast is the issue - when the method is a local function, its containing symbol might be a method. @jtschuster would you mind taking a look?

@JamesNK
Copy link
Member

JamesNK commented Nov 10, 2022

FYI this issue impacts the dotnet/aspnetcore repository and blocks us from updating the SDK. It's not urgent to update the SDK, but prompt progress would be appreciated.

@jtschuster
Copy link
Member

The fix is checked in and flowing to sdk in dotnet/sdk#29013

@jtschuster
Copy link
Member

The change should now be in the installer repo from dotnet/installer#14951, but that build failed to publish https://dev.azure.com/dnceng/internal/_build/results?buildId=2042975&view=results.

@jtschuster
Copy link
Member

Closing since it looks like there's a separate issue holding up the ASP.Net PR

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

4 participants