Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SA1500 FixAll exception #2105

Closed
kindermannhubert opened this issue Mar 16, 2016 · 1 comment
Closed

SA1500 FixAll exception #2105

kindermannhubert opened this issue Mar 16, 2016 · 1 comment
Assignees
Milestone

Comments

@kindermannhubert
Copy link

Hi, I observed NullReferenceException while using SA1500 FixAll provider.

It happened in StyleCop.Analyzers.Helpers.LocationHelpers.GetLineSpan(this SyntaxToken token) while SyntaxToken was None (I guess default value) so the 'token.SyntaxTree' was null.

In method SA1500CodeFixProvider.GenerateBraceFixes the state was:
'braceToken' = CloseBraceToken
'previousToken' = CloseBraceToken
'nextToken' = None
then there follows call 'LocationHelpers.GetLineSpan(nextToken)'.

Stack is here:

   at StyleCop.Analyzers.Helpers.LocationHelpers.GetLineSpan(SyntaxToken token)
   at StyleCop.Analyzers.LayoutRules.SA1500CodeFixProvider.GenerateBraceFixes(Document document, IndentationSettings indentationSettings, ImmutableArray`1 braceTokens)
   at StyleCop.Analyzers.LayoutRules.SA1500CodeFixProvider.FixAll.<FixAllInDocumentAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at StyleCop.Analyzers.Helpers.DocumentBasedFixAllProvider.<GetSolutionFixesAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__9.MoveNext()
@vweijsters
Copy link
Contributor

Thanks for reporting this. I had no trouble in reproducing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants