roslyn: ExtractMethodCodeRefactoringProvider encountered an error and has been disabled.
This issue has been moved from a ticket on Developer Community.
This error was reported many times before but the problem still exists. During refactoring code the info bar pops up. Or can we disable the info bar at all because I can do nothing here?
System.InvalidOperationException : Unexpected Null
at Roslyn.Utilities.Contract.ThrowIfNull[T](T value,String message)
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.GetCallSiteContainerFromExpression()
at Microsoft.CodeAnalysis.CSharp.ExtractMethod.CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.GetOutermostCallSiteContainerToProcess(CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.CodeGenerator`3.GenerateAsync[TStatement,TExpression,TNodeUnderContainer](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService`3.ExtractMethodAsync[TValidator,TExtractor,TResult](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.GetCodeActionAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
Original Comments
Visual Studio Feedback System on 10/23/2019, 02:29 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Visual Studio Feedback System on 10/23/2019, 04:47 PM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.
kapenaga [MSFT] on 12/13/2019, 08:08 AM:
Faced same issue today. here is the stack trace.
System.NullReferenceException : Object reference not set to an instance of an object.
at Microsoft.CodeAnalysis.CSharp.SyntaxFactory.FindConditionalAccessNodeForBinding(CSharpSyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.Binder.GetReceiverForConditionalBinding(ExpressionSyntax binding,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindMemberBindingExpression(MemberBindingExpressionSyntax node,Boolean invoked,Boolean indexed,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node,DiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node,DiagnosticBag diagnostics,Boolean invoked,Boolean indexed)
at Microsoft.CodeAnalysis.CSharp.Binder.BindReturn(ReturnStatementSyntax syntax,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.IncrementalBinder.BindStatement(StatementSyntax node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindBlockParts(BlockSyntax node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.IncrementalBinder.BindEmbeddedBlock(BlockSyntax node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindLocalFunctionStatement(LocalFunctionStatementSyntax node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.IncrementalBinder.BindStatement(StatementSyntax node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.Bind(Binder binder,CSharpSyntaxNode node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.MethodBodySemanticModel.Bind(Binder binder,CSharpSyntaxNode node,DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(CSharpSyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetLowerBoundNode(CSharpSyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetBoundNodes(CSharpSyntaxNode node,CSharpSyntaxNode& bindableNode,BoundNode& lowestBoundNode,BoundNode& highestBoundNode,BoundNode& boundParent)
at Microsoft.CodeAnalysis.CSharp.MemberSemanticModel.GetSymbolInfoWorker(CSharpSyntaxNode node,SymbolInfoOptions options,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel.GetSymbolInfoWorker(CSharpSyntaxNode node,SymbolInfoOptions options,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfo(ExpressionSyntax expression,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoFromNode(SyntaxNode node,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.CSharpSemanticModel.GetSymbolInfoCore(SyntaxNode node,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Simplification.SimplificationHelpers.GetOriginalSymbolInfo(SemanticModel semanticModel,SyntaxNode expression)
at Microsoft.CodeAnalysis.CSharp.Extensions.ExpressionSyntaxExtensions.TryReduce(NameSyntax name,SemanticModel semanticModel,TypeSyntax& replacementNode,TextSpan& issueSpan,OptionSet optionSet,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Extensions.ExpressionSyntaxExtensions.TryReduceExplicitName(ExpressionSyntax expression,SemanticModel semanticModel,TypeSyntax& replacementNode,TextSpan& issueSpan,OptionSet optionSet,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Extensions.ExpressionSyntaxExtensions.TryReduceOrSimplifyExplicitName(ExpressionSyntax expression,SemanticModel semanticModel,ExpressionSyntax& replacementNode,TextSpan& issueSpan,OptionSet optionSet,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Simplification.CSharpNameReducer.SimplifyName(SyntaxNode node,SemanticModel semanticModel,OptionSet optionSet,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Simplification.AbstractCSharpReducer.AbstractReductionRewriter.SimplifyNode[TNode](TNode node,SyntaxNode newNode,SyntaxNode parentNode,Func5 simplifier)<br> at Microsoft.CodeAnalysis.CSharp.Simplification.AbstractCSharpReducer.AbstractReductionRewriter.SimplifyExpression[TExpression](TExpression expression,SyntaxNode newNode,Func
5 simplifier)
at Microsoft.CodeAnalysis.CSharp.Simplification.CSharpNameReducer.Rewriter.VisitIdentifierName(IdentifierNameSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax.Accept[TResult](CSharpSyntaxVisitor1 visitor)<br> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)<br> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitAliasQualifiedName(AliasQualifiedNameSyntax node)<br> at Microsoft.CodeAnalysis.CSharp.Simplification.CSharpNameReducer.Rewriter.VisitAliasQualifiedName(AliasQualifiedNameSyntax node)<br> at Microsoft.CodeAnalysis.CSharp.Syntax.AliasQualifiedNameSyntax.Accept[TResult](CSharpSyntaxVisitor
1 visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitQualifiedName(QualifiedNameSyntax node)
at Microsoft.CodeAnalysis.CSharp.Simplification.CSharpNameReducer.Rewriter.VisitQualifiedName(QualifiedNameSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.QualifiedNameSyntax.Accept[TResult](CSharpSyntaxVisitor1 visitor)<br> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)<br> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitLocalFunctionStatement(LocalFunctionStatementSyntax node)<br> at Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax.Accept[TResult](CSharpSyntaxVisitor
1 visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.Simplification.AbstractCSharpReducer.AbstractReductionRewriter.VisitNodeOrToken(SyntaxNodeOrToken nodeOrToken,SemanticModel semanticModel,Boolean simplifyAllDescendants)
at async Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService3.<>c__DisplayClass10_1.<ReduceAsync>b__0[TExpressionSyntax,TStatementSyntax,TCrefSyntax](<Unknown Parameters>)<br> at async Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService
3.ReduceAsyncInternal[TExpressionSyntax,TStatementSyntax,TCrefSyntax](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService3.ReduceAsync[TExpressionSyntax,TStatementSyntax,TCrefSyntax](<Unknown Parameters>)<br> at async Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(<Unknown Parameters>)<br> at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.CodeGenerator
3.GenerateAsync[TStatement,TExpression,TNodeUnderContainer](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService`3.ExtractMethodAsync[TValidator,TExtractor,TResult](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ExtractLocalFunction(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.GetCodeActionsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
ivan.tsitovich on 1/28/2020, 11:32 AM:
I see similar problem
VS 2019 16.4.3
System.InvalidOperationException : Unexpected false
at Roslyn.Utilities.Contract.ThrowIfFalse(Boolean condition,String message)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.LocalVariableSymbol1.GetOriginalIdentifierToken(CancellationToken cancellationToken)<br> at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.LocalVariableSymbol
1.AddIdentifierTokenAnnotationPair(List1 annotations,CancellationToken cancellationToken)<br> at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.<>c__DisplayClass18_0.<CreateDocumentWithAnnotationsAsync>b__0(VariableInfo v)<br> at Roslyn.Utilities.EnumerableExtensions.Do[T](IEnumerable
1 source,Action1 action)<br> at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.CreateDocumentWithAnnotationsAsync(SemanticDocument document,IList
1 variables,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.AnalyzeAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService`3.ExtractMethodAsync[TValidator,TExtractor,TResult](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.GetCodeActionAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
Original Solutions
(no solutions)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 22 (11 by maintainers)
These seems to be reports of the same issue: dotnet/roslyn#41478, dotnet/roslyn#41895, dotnet/roslyn#42504