You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Analyzer 'NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantSetupAnalyzer' threw an exception of type 'System.ArgumentException' with message 'SyntaxTree is not part of the compilation'
#56
Closed
meziantou opened this issue
Dec 4, 2018
· 5 comments
· Fixed by #58
Severity Code Description Project File Line Suppression State Detail Description
Warning AD0001 Analyzer 'NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantSetupAnalyzer' threw an exception of type 'System.ArgumentException' with message 'SyntaxTree is not part of the compilation
Parameter name: syntaxTree'. ***** 1 Active Analyzer 'NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantSetupAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: *****
SyntaxTree: C:\Users\Tests.cs
SyntaxNode: preferenceCollection.Get(@"t:\a.csproj" ... [InvocationExpressionSyntax]@[474..540) (15,12)-(15,78)
System.ArgumentException: SyntaxTree is not part of the compilation
Parameter name: syntaxTree
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSemanticModel(SyntaxTree syntaxTree, Boolean ignoreAccessibility)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonGetSemanticModel(SyntaxTree syntaxTree, Boolean ignoreAccessibility)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitArrowExpressionClause(ArrowExpressionClauseSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitAccessorDeclaration(AccessorDeclarationSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitAccessorList(AccessorListSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.AccessorListSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitPropertyDeclaration(PropertyDeclarationSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitClassDeclaration(ClassDeclarationSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.VisitRelatedSymbols(SyntaxNode syntaxNode)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitIdentifierName(IdentifierNameSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.ReEntrantCallVisitor.DefaultVisit(SyntaxNode node)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.ObjectCreationExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
at NSubstitute.Analyzers.CSharp.DiagnosticAnalyzers.ReEntrantCallFinder.GetReEntrantSymbols(Compilation compilation, SyntaxNode rootNode)
at NSubstitute.Analyzers.Shared.DiagnosticAnalyzers.AbstractReEntrantCallFinder.GetReEntrantCalls(Compilation compilation, SyntaxNode rootNode)
at NSubstitute.Analyzers.Shared.DiagnosticAnalyzers.AbstractReEntrantSetupAnalyzer`2.AnalyzeInvocation(SyntaxNodeAnalysisContext syntaxNodeContext)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__44`1.<ExecuteSyntaxNodeAction>b__44_0(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
The text was updated successfully, but these errors were encountered:
Hi,
Thanks for reporting. We had similar issue some time ago #46, we thought we fixed it, but apperently there is another way of reproducing it. Is there any chance you could share sample project to reproduce this one? Having that I would be able to add proper integration tests otherwise I will have to fix it "blindly"
Sorry for the delay. My project is private, so I cannot share it with you. I tried to create a repro project without success.
I also tried to clone the repository and start the NSubstitute.Analyzers.CSharp.Vsix project to debug the problem on my side. However, it seems the extension is not loaded. What's the easiest way to debug a solution?
@meziantou vsix was supposed to be the easiest way to debug analyzers. I tested this on some older Visual Studio instances and it worked as expected. However I ve never had a chance to test it on the newer versions as I dont have a license. One way or another, I will provide the fix for this bug once I am back from my holidays(I think I know where the problem is, even though I cannot repro it)
Hi,
I got this exception on my project:
The text was updated successfully, but these errors were encountered: