question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

exception in errorlist

See original GitHub issue

I get several exceptions in the error list: The stack traces seems to be identical for all of them, see below for one of them. A lot of the analyzers mentioned in the stack traces don’t seem to apply for my test method?

I haven’t been able to come up with an example that triggers the bug. Any ideas?

Severity	Code	Description	Project	File	Line	Suppression State	Detail Description
Warning	AD0001	Analyzer 'FluentAssertions.BestPractices.CollectionShouldEqualOtherCollectionByComparerAnalyzer' threw an exception of type 'System.ArgumentException' with message 'An item with the same key has already been added.'.	CIUnitTests		1	Active	Analyzer 'FluentAssertions.BestPractices.CollectionShouldEqualOtherCollectionByComparerAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: CIUnitTests
ISymbol: MyTest (Method)
SyntaxTree: C:\Test.cs
SyntaxNode: [TestMethod] public void MyTest ... [MethodDeclarationSyntax]@[8641..10638) (200,8)-(232,9)

System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at FluentAssertions.BestPractices.FluentAssertionsWithArgumentsCSharpSyntaxVisitor.VisitArguments(SeparatedSyntaxList`1 arguments)
   at FluentAssertions.BestPractices.FluentAssertionsWithArgumentsCSharpSyntaxVisitor.VisitArgumentList(ArgumentListSyntax node)
   at Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentListSyntax.Accept(CSharpSyntaxVisitor visitor)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
   at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.Visit(SyntaxNode node)
   at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.VisitInvocationExpression(InvocationExpressionSyntax node)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
   at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.Visit(SyntaxNode node)
   at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.VisitExpressionStatement(ExpressionStatementSyntax node)
   at Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax.Accept(CSharpSyntaxVisitor visitor)
   at FluentAssertions.BestPractices.FluentAssertionsAnalyzer`1.AnalyzeExpressionStatement(ExpressionStatementSyntax statement)
   at FluentAssertions.BestPractices.FluentAssertionsAnalyzer`1.AnalyzeCodeBlock(CodeBlockAnalysisContext context)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__48`2.<ExecuteBlockActions>b__48_0(ValueTuple`2 data)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----
'.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Meir017commented, Oct 22, 2017

I had a feeling it’s something like this…

Looks like another redesign to the FluentAssertionsWithArgumentsCSharpSyntaxVisitor class which extracts the methods into a dictionary containing for each method its arguments.

I’m going to add a SanityTests class (not sure about the name yet) that will include cases the should not throw exceptions (and no diagnostics), this will help

0reactions
jnyrupcommented, Oct 23, 2017

As of Fluent Assertions 5.0, I guess you should be able to do so. The API has been changed, so all assertions now start with Should(). E.g. ShouldThrow() and ShouldBeEquivalent() are now Should().Throw() and Should().BeEquivalent().

Most assertions return an AndConstraint which is a continutation on the same assertions. Others return an AndWhichConstraint which allows you to either continue on the same assertion (the And part) or begin an assertion on some result from the assertions. There is also WhichValueConstraint.

E.g. ContainSingle() return and AndWhich which lets you assert on that single element.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Built-in Exceptions — Python 3.11.4 documentation
In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that...
Read more >
Am I handling my exceptions in a sensible manner?
Instead of using the separate variable ErrorList , it is better to either generate the user-visible message at the point where you display...
Read more >
Control.Exception.ErrorList
0.3: A useful type for collecting error messages. Safe Haskell, None. Language, Haskell2010. Control.Exception.ErrorList.
Read more >
Error List Window - Visual Studio
The Error List displays information about a specific error message. You can copy the error number or error string text from the Output...
Read more >
Error List stops updating after exception of type ...
Soon after this notice appears, the Error List… stops updating and the error highlights in the code never go away. I tried things...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found