-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
MarshallingAttributeAnalyzers throws InvalidCastException #75681
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
If you can figure out which syntax the analyzer is inspecting when it fails, that would be a good minimal repro that we could use to diagnose and fix the failure. |
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsDescriptionNativeMarshallingAttributeAnalyzer and CustomMarshallerAttributeAnalyzer are throwing exceptions when building the runtime repo. Reproduction StepsI upgraded an existing ADO pipeline to use .NET 7 RC 1 and it started to fail. Expected behaviorNo errors Actual behavior##[error]CSC(0,0): Error AD0001: Analyzer 'Microsoft.Interop.Analyzers.NativeMarshallingAttributeAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.NonErrorNamedTypeSymbol' to type 'Microsoft.CodeAnalysis.IMethodSymbol'.'. Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationSeems similar to #72622 , but this time with InvalidCastException instead of InvalidOperationException.
|
This issue has been marked |
We spoke offline and determined that the failure case is an attribute on the return type of a delegate: [return: Attr]
delegate int X(); In this case, the containing symbol is a type, not a method. |
Fix two customer-discovered edge cases that were causing analyzer crashes. Fixes dotnet#75681 Fixes dotnet#75706
Description
NativeMarshallingAttributeAnalyzer and CustomMarshallerAttributeAnalyzer are throwing exceptions when building the runtime repo.
Reproduction Steps
I upgraded an existing ADO pipeline to use .NET 7 RC 1 and it started to fail.
I have no idea what configuration in repo is relevant for repro, I'll be happy to share more details and link to pipeline as needed.
Expected behavior
No errors
Actual behavior
##[error]CSC(0,0): Error AD0001: Analyzer 'Microsoft.Interop.Analyzers.NativeMarshallingAttributeAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.NonErrorNamedTypeSymbol' to type 'Microsoft.CodeAnalysis.IMethodSymbol'.'.
7>CSC : error AD0001: Analyzer 'Microsoft.Interop.Analyzers.NativeMarshallingAttributeAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.NonErrorNamedTypeSymbol' to type 'Microsoft.CodeAnalysis.IMethodSymbol'.'. [D:\a_work\10\s\src\Product\UITester.Mac\Microsoft.Mashup.Client.UITester.Mac.csproj]
##[error]CSC(0,0): Error AD0001: Analyzer 'Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.NonErrorNamedTypeSymbol' to type 'Microsoft.CodeAnalysis.IMethodSymbol'.'.
7>CSC : error AD0001: Analyzer 'Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.NonErrorNamedTypeSymbol' to type 'Microsoft.CodeAnalysis.IMethodSymbol'.'. [D:\a_work\10\s\src\Product\UITester.Mac\Microsoft.Mashup.Client.UITester.Mac.csproj]
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
Seems similar to #72622 , but this time with InvalidCastException instead of InvalidOperationException.
The text was updated successfully, but these errors were encountered: