DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.61k stars 506 forks source link

SA1404 throws NullReferenceException #3829

Closed ValentijnMakkenze closed 2 months ago

ValentijnMakkenze commented 2 months ago

We are getting these warnings during the build

CSC warning AD0001: Analyzer 'StyleCop.Analyzers.MaintainabilityRules.SA1404CodeAnalysisSuppressionMustHaveJustification' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.

Exception occurred with following context:
Compilation: GVRCommunicator.Core.Tests
SyntaxTree: F:\Git\Neuron Stelsel Registratie\Communicator\GVRCommunicator.Core.Tests\BLL\Simple\TestBusComEntiteit.cs
SyntaxNode: global::Rollback [AttributeSyntax]@[972..988) (32,5)-(32,21)
System.NullReferenceException: Object reference not set to an instance of an object.
at StyleCop.Analyzers.MaintainabilityRules.SA1404CodeAnalysisSuppressionMustHaveJustification.AnalyzerInstance.HandleAttributeNode(SyntaxNodeAnalysisContext context)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__52`1.<ExecuteSyntaxNodeAction>b__52_0(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)

The classes where this happens have a global attribute like this

[Test]
[global::Rollback]
public void Test()
{