Skip to content

MarshallingAttributeAnalyzers throws InvalidOperationException #72622

Description

@sbomer

Description

NativeMarshallingAttributeAnalyzer and CustomMarshallerAttributeAnalyzer are throwing exceptions when building the runtime repo.

Reproduction Steps

Set dotnet_diagnostic.AD0001.severity = error in eng/CodeAnalysis.src.globalconfig, and run build.cmd

Expected behavior

No errors

Actual behavior

I get lots of errors like the following:

CSC : error AD0001: Analyzer 'Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer' threw an exception of type 'System.InvalidOperationException' with me 
ssage 'Sequence contains no elements'. [C:\Users\svbomer\src\runtime\src\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj]
CSC : error AD0001: Analyzer 'Microsoft.Interop.Analyzers.NativeMarshallingAttributeAnalyzer' threw an exception of type 'System.InvalidOperationException' with m 
essage 'Sequence contains no elements'. [C:\Users\svbomer\src\runtime\src\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj]
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.ArrayTypeSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'.'. [C:\Users\svbomer\src\runtime\src\coreclr\nativeaot\System.Private.CoreLib\src\System.Private.CoreLib.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@jkoritzinsky

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Jul 21, 2022
  2. jkoritzinsky commented on Jul 21, 2022

    @jkoritzinsky
    Member

    This will be fixed by #72620

  3. added
    source-generatorIndicates an issue with a source generator feature
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Jul 21, 2022
  4. added this to the 7.0.0 milestone on Jul 21, 2022
  5. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 21, 2022
  6. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 21, 2022
  7. sbomer commented on Jul 21, 2022

    @sbomer
    MemberAuthor

    I'm still seeing errors like this:

    CSC : error AD0001: Analyzer 'Microsoft.Interop.Analyzers.CustomMarshallerAttributeAnalyzer' threw an exception of type 'System.InvalidCastExceptio
    n' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.ArrayTypeSymbol' to type 'Microsoft.CodeAnalysis.
    INamedTypeSymbol'.'. [C:\Users\svbomer\src\runtime\src\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj]
    
  8. reopened this on Jul 21, 2022
  9. jkoritzinsky commented on Jul 21, 2022

    @jkoritzinsky
    Member

    :( Why did I decide to try to be a kinder citizen in the VS ecosystem and work off of syntax instead of symbols until I can use operations???

    I'll take a look

  10. jkoritzinsky commented on Jul 21, 2022

    @jkoritzinsky
    Member

    Also I didn't realize we had AD0001 disabled locally. That will make this much easier to debug

  11. jkoritzinsky commented on Jul 21, 2022

    @jkoritzinsky
    Member

    Actually, this looks like a different bug. I'll include this one in my PR that adds more support for other things to the analyzer, as I'm about to put out the PR for it and the work would conflict.

  12. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 21, 2022
  13. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 26, 2022
  14. ghost locked as resolved and limited conversation to collaborators on Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions