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
Hi,
I updated VS till 15.5 release version and I get the following exception.
I tried 6.4.1.3596 and 6.7.0.4267 versions of SonarAnalyzer.CSharp package.
Thank you.
using System;
namespace ConsoleApp8
{
class Program
{
static void Main(string[] args)
{
}
public Program(string id)
{
if (string.IsNullOrEmpty(id)) throw new ArgumentNullException(nameof(id));
}
}
}
Analyzer 'SonarAnalyzer.Rules.CSharp.EmptyCollectionsShouldNotBeEnumerated' threw the following exception:
'Exception occurred with following context:
Compilation: ConsoleApp8
SyntaxTree: C:\Workplace\Temp\ConsoleApp8\ConsoleApp8\Program.cs
SyntaxNode: Program(string id) { if (id < 1 ... [ConstructorDeclarationSyntax]@[358..498) (15,8)-(20,9)
System.InvalidOperationException: This operation does not apply to an empty instance.
at System.Collections.Immutable.ImmutableStack`1.Peek()
at SonarAnalyzer.SymbolicExecution.ProgramState.PopValue(SymbolicValue& poppedValue)
at SonarAnalyzer.Rules.CSharp.EmptyCollectionsShouldNotBeEnumerated.EmptyCollectionAccessedCheck.<>c__DisplayClass15_0.<GetArgumentSymbolicValues>b__0(ArgumentSyntax argument)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
at SonarAnalyzer.Rules.CSharp.EmptyCollectionsShouldNotBeEnumerated.EmptyCollectionAccessedCheck.RemoveCollectionConstraintsFromArguments(ArgumentListSyntax argumentList, ProgramState programState)
at SonarAnalyzer.Rules.CSharp.EmptyCollectionsShouldNotBeEnumerated.EmptyCollectionAccessedCheck.ProcessInvocation(ProgramState programState, InvocationExpressionSyntax invocation)
at SonarAnalyzer.Rules.CSharp.EmptyCollectionsShouldNotBeEnumerated.EmptyCollectionAccessedCheck.PreProcessInstruction(ProgramPoint programPoint, ProgramState programState)
at SonarAnalyzer.SymbolicExecution.CSharpExplodedGraph.<>c__DisplayClass3_0.<VisitInstruction>b__0(ProgramState ps, ExplodedGraphCheck check)
at SonarAnalyzer.SymbolicExecution.CSharpExplodedGraph.<>c__DisplayClass4_0.<InvokeChecks>b__0(ProgramState ps, ExplodedGraphCheck check)
at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
at SonarAnalyzer.SymbolicExecution.CSharpExplodedGraph.InvokeChecks(ProgramState programState, Func`3 invoke)
at SonarAnalyzer.SymbolicExecution.CSharpExplodedGraph.VisitInstruction(ExplodedGraphNode node)
at SonarAnalyzer.SymbolicExecution.AbstractExplodedGraph.Walk()
at SonarAnalyzer.Rules.CSharp.EmptyCollectionsShouldNotBeEnumerated.CheckForEmptyCollectionAccess(CSharpExplodedGraph explodedGraph, SyntaxNodeAnalysisContext context)
at SonarAnalyzer.SymbolicExecution.FlowAnalysisExtensions.Analyze(CSharpSyntaxNode declarationBody, ISymbol symbol, Action`2 analyze, SyntaxNodeAnalysisContext context)
at SonarAnalyzer.SymbolicExecution.FlowAnalysisExtensions.<>c__DisplayClass0_0.<RegisterExplodedGraphBasedAnalysis>b__0(SyntaxNodeAnalysisContext c)
at SonarAnalyzer.Helpers.DiagnosticAnalyzerContextHelper.<>c__DisplayClass0_0`1.<RegisterSyntaxNodeActionInNonGenerated>b__0(SyntaxNodeAnalysisContext c)
at SonarAnalyzer.Helpers.SonarAnalysisContext.<>c__DisplayClass16_0`1.<RegisterSyntaxNodeAction>b__0(SyntaxNodeAnalysisContext c)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__43`1.<ExecuteSyntaxNodeAction>b__43_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:
Evangelink
changed the title
InvalidOperationException in EmptyCollectionsShouldNotBeEnumerated [VS 15.5 only]
Fix EmptyCollectionsShouldNotBeEnumerated: Rule should not throw InvalidOperationException
Dec 18, 2017
valhristov
changed the title
Fix EmptyCollectionsShouldNotBeEnumerated: Rule should not throw InvalidOperationException
Fix S4158: "Empty Collections Should Not Be Enumerated" should not throw InvalidOperationException
Dec 21, 2017
Hi,
I updated VS till 15.5 release version and I get the following exception.
I tried 6.4.1.3596 and 6.7.0.4267 versions of SonarAnalyzer.CSharp package.
Thank you.
The text was updated successfully, but these errors were encountered: