Skip to content

COMAnalyzer NullReferenceException in Maui Essentials #2686

@eerhardt

Description

@eerhardt

I'm getting the following error when setting IsTrimmable=true for the Maui Essentials project and building with msbuild Essentials.csproj -p:Configuration=Release -t:Rebuild /bl:

    Errors
        CSC error AD0001: Analyzer 'ILLink.RoslynAnalyzer.COMAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [C:\git\maui\src\Essentials\src\Essentials.csproj]
    Exception occurred with following context:
    Compilation: Microsoft.Maui.Essentials
    IOperation: Invocation
    SyntaxTree: C:\git\maui\src\Essentials\src\DeviceDisplay\DeviceDisplay.uwp.cs
    SyntaxNode: EnumDisplaySettings(mi.Value.DeviceNameToLPTStr ... [InvocationExpressionSyntax]@[2465..2533) (101,3)-(101,71)
    System.NullReferenceException: Object reference not set to an instance of an object.
    at ILLink.RoslynAnalyzer.COMAnalyzer.<Initialize>g__IsComInterop|6_1(ISymbol symbol)
    at ILLink.RoslynAnalyzer.COMAnalyzer.<>c.<Initialize>b__6_2(OperationAnalysisContext operationContext)
    at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteOperationAction>b__63_0(ValueTuple`2 data)
    at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
    -----
    Suppress the following diagnostics to disable this analyzer: IL2050
    CompilerServer: server - server processed compilation - 1477aa4a-10c1-4109-b699-b092d24b4231

This looks like #2622, but I believe it is a different issue because this method isn't using a pointer, and because the version of the ILLink.RoslynAnalyzer assembly I'm using is from https://github.com/dotnet/linker/commits/e9cfb5413a6a7a7b5bfc3b9a73671be2b18642cf, which has the fix for #2622.

To Repro

  1. git clone https://github.com/dotnet/maui
  2. check out this commit: dotnet/maui@7a6d62f
  3. C:\git\maui\src\Essentials\src>msbuild Essentials.csproj -p:Configuration=Release -t:Rebuild /bl

cc @tlakollo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions