Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

.NET 6.0.200-rtm.22077.13 hits NRE in ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer #2563

Closed

Description

@jonathanpeppers

Saw this here: dotnet/android#6670

Bumping from .NET 6.0.200-rtm.22074.2 to 6.0.200-rtm.22077.13

Diff: d0662ed...70dc7f6

A Xamarin.Forms test project started hitting the warning:

CSC warning AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.

It seems I can workaround for now, by passing -p:EnableSingleFileAnalyzer=false.

Activity

  1. sbomer commented on Jan 28, 2022

    @sbomer
    Member

    Full stacktrace from the build logs:

    15:26:15.554   1:7>CSC : warning AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [/Users/runner/work/1/a/TestRelease/01-28_14.45.22/temp/BuildHasNoWarningsFalseTrueTrueapk/UnnamedProject.csproj]
                         Exception occurred with following context: (TaskId:168)
                         Compilation: UnnamedProject (TaskId:168)
                         IOperation: FieldReference (TaskId:168)
                         SyntaxTree: /Users/runner/work/1/a/TestRelease/01-28_14.45.22/temp/BuildHasNoWarningsFalseTrueTrueapk/App.xaml.cs (TaskId:168)
                         SyntaxNode: XamlCompilationOptions.Compile [MemberAccessExpressionSyntax]@[90..120) (4,28)-(4,58) (TaskId:168)
                         System.NullReferenceException: Object reference not set to an instance of an object. (TaskId:168)
                         at ILLink.RoslynAnalyzer.ISymbolExtensions.HasAttribute(ISymbol symbol, String attributeName) (TaskId:168)
                         at ILLink.RoslynAnalyzer.RequiresISymbolExtensions.IsInRequiresScope(ISymbol member, String requiresAttribute, Boolean checkAssociatedSymbol) (TaskId:168)
                         at ILLink.RoslynAnalyzer.RequiresAnalyzerBase.<Initialize>g__CheckCalledMember|19_14(OperationAnalysisContext operationContext, ISymbol member, ImmutableArray`1 incompatibleMembers) (TaskId:168)
                         at ILLink.RoslynAnalyzer.RequiresAnalyzerBase.<>c__DisplayClass19_0.<Initialize>b__8(OperationAnalysisContext operationContext) (TaskId:168)
                         at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info) (TaskId:168)
                         ----- (TaskId:168)
    
    

    Looks similar to the issue fixed (in main) here: #2534

  2. jonathanpeppers commented on Jan 28, 2022

    @jonathanpeppers
    MemberAuthor

    Can that fix go to the release/6.0.2xx branch?

  3. sbomer commented on Jan 28, 2022

    @sbomer
    Member

    @agocke should we take #2530 into 6.0.2xx? I wasn't able to confirm definitively whether xamarin-android hit this because of an assembly-level attribute, but I think there's a high chance it's the same issue.

  4. agocke commented on Jan 28, 2022

    @agocke
    Member

    Yup, let's do it.

  5. jonathanpeppers commented on Jan 29, 2022

    @jonathanpeppers
    MemberAuthor

    Sorry it is:

    Csc
        ...
        Warnings
            CSC warning AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [/Users/runner/work/1/a/TestRelease/01-28_14.45.22/temp/BuildHasNoWarningsFalseTrueFalseapk/UnnamedProject.csproj]
        Exception occurred with following context:
        Compilation: UnnamedProject
        IOperation: FieldReference
        SyntaxTree: /Users/runner/work/1/a/TestRelease/01-28_14.45.22/temp/BuildHasNoWarningsFalseTrueFalseapk/App.xaml.cs
        SyntaxNode: XamlCompilationOptions.Compile [MemberAccessExpressionSyntax]@[90..120) (4,28)-(4,58)
        System.NullReferenceException: Object reference not set to an instance of an object.
        at ILLink.RoslynAnalyzer.ISymbolExtensions.HasAttribute(ISymbol symbol, String attributeName)
        at ILLink.RoslynAnalyzer.RequiresISymbolExtensions.IsInRequiresScope(ISymbol member, String requiresAttribute, Boolean checkAssociatedSymbol)
        at ILLink.RoslynAnalyzer.RequiresAnalyzerBase.<Initialize>g__CheckCalledMember|19_14(OperationAnalysisContext operationContext, ISymbol member, ImmutableArray`1 incompatibleMembers)
        at ILLink.RoslynAnalyzer.RequiresAnalyzerBase.<>c__DisplayClass19_0.<Initialize>b__8(OperationAnalysisContext operationContext)
        at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
    

    I forgot to attach the .binlog before: illink.zip

  6. sbomer commented on Jan 29, 2022

    @sbomer
    Member

    Thanks @jonathanpeppers. Do you happen to have the BuildHasNoWarningsFalseTrueFalseapk/App.xaml.cs at hand? That would help confirm whether it's hit for an assembly-level attribute. From the stacktrace though, it looks like the same issue.

  7. jonathanpeppers commented on Jan 29, 2022

    @jonathanpeppers
    MemberAuthor

    Yes, it has:

    using System;
    using Xamarin.Forms;
    using Xamarin.Forms.Xaml;
    
    [assembly: XamlCompilation (XamlCompilationOptions.Compile)]
    namespace UnnamedProject
    {
    	public partial class App : Application
    	{
    		public App ()
    		{
    			InitializeComponent ();
    
    			MainPage = new MainPage ();
    		}
    	}
    }
  8. added 3 commits that reference this issue on Jan 31, 2022
  9. agocke commented on Feb 11, 2022

    @agocke
    Member

    Should have been fixed by #2530

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions