-
Versions used (SonarQube, Scanner, Plugin, and any relevant extension)
- VS2017 15.9.44
- SonarLint:5.4.0.42421
-
Error observed (wrap logs/code around triple quote ``` for proper formatting)
System.InvalidCastException : Unable to cast object of type 'Microsoft.CodeAnalysis.Operations.LazyIsTypeExpression' to type 'Microsoft.CodeAnalysis.Operations.IBinaryOperation'.
at Microsoft.CodeAnalysis.CodeRefactorings.InvertIf.AbstractInvertIfCodeRefactoringProvider.GetNegationOfBinaryExpression(SyntaxNode expressionNode,SyntaxGenerator generator,ISyntaxFactsService syntaxFacts,SemanticModel semanticModel,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CodeRefactorings.InvertIf.AbstractInvertIfCodeRefactoringProvider.Negate(SyntaxNode expression,SyntaxGenerator generator,ISyntaxFactsService syntaxFacts,SemanticModel semanticModel,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.CodeRefactorings.InvertIf.CSharpInvertIfCodeRefactoringProvider.GetRootWithInvertIfStatement(Document document,SemanticModel model,SyntaxNode ifStatementSyntax,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.CodeRefactorings.InvertIf.AbstractInvertIfCodeRefactoringProvider.InvertIfAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
- Steps to reproduce
Trying to use the suppress to file with the solution option for a “Replace this type-check-and-cast sequence with an ‘as’ and a null check.” warning. Note that this was combined with a “Use pattern matching” suggestion for the same block of code.