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
- Checkout https://github.com/dotnet/aspnetcore/tree/98bd1e8085ba090a352ed1eda7f86fd2bd5381ea
- Build the solution following these steps
Expected behavior
The build completes successfully.
Actual behavior
The build fails with the aforementioned error.