Skip to content

SA1008 threw a NullReferenceException #2354

@appel1

Description

@appel1

Using StyleCopAnalyzers 1.0 in VS2017 for a .NET 4.5 project, C#6. While refactoring I got the following error. At some point during my refactorings the file referenced in the error was removed, don't know if that is related or if this error occurred before that.

Severity	Code	Description	Project	File	Line	Suppression State	Detail Description
Warning	AD0001	Analyzer 'StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.	<project>	1	Active	Analyzer 'StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly' threw the following exception:
'Exception occurred with following context:
Compilation: <project>
SyntaxTree: <source path>

System.NullReferenceException: Object reference not set to an instance of an object.
   at StyleCop.Analyzers.Helpers.LocationHelpers.GetLineSpan(SyntaxToken token)
   at StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly.HandleOpenParenToken(SyntaxTreeAnalysisContext context, SyntaxToken token)
   at StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly.HandleSyntaxTree(SyntaxTreeAnalysisContext context)
   at StyleCop.Analyzers.AnalyzerExtensions.<>c__DisplayClass2_0.<RegisterSyntaxTreeActionHonorExclusions>b__0(SyntaxTreeAnalysisContext c)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass41_0.<ExecuteSyntaxTreeActionsCore>b__0()
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info)
-----
'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions