Skip to content

MarshallingAttributeAnalyzers throws InvalidCastException #75681

@idigra

Description

@idigra

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions