fluentassertions.analyzers icon indicating copy to clipboard operation
fluentassertions.analyzers copied to clipboard

InvalidOperationException during build

Open FantasyTeddy opened this issue 5 years ago • 8 comments

Description

In some of my projects I get the following error when building:

CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'This operation does not apply to an empty instance.'.

My guess is that the following IsEmpty check should happen before Peek(): https://github.com/fluentassertions/fluentassertions.analyzers/blob/686a33bb1cd40ea01fffeea8d4ef85e481271d32/src/FluentAssertions.Analyzers/Utilities/FluentAssertionsCSharpSyntaxVisitor.cs#L74-L78

If you need me to provide more information, let me know how and I will see what I can do.

Versions

  • FluentAssertions.Analyzers 0.11.3
  • .NET Framework 4.6.1

FantasyTeddy avatar Aug 17 '18 13:08 FantasyTeddy

can you provide a minimal code sample that will reproduce this error?

Meir017 avatar Aug 17 '18 14:08 Meir017

Unfortunately not, because I don't know what's causing this to happen. The Debug output is not very informative and only tells me what I copied above. How could I trace this down to see where the exception actually happens?

FantasyTeddy avatar Aug 17 '18 14:08 FantasyTeddy

@FantasyTeddy just released 0.11.4

Meir017 avatar Aug 17 '18 15:08 Meir017

Unfortunately my guess was incorrect, I still have this exception in two of my projects with the new version...

FantasyTeddy avatar Aug 20 '18 05:08 FantasyTeddy

Could you create a repository with your code?

Meir017 avatar Aug 20 '18 05:08 Meir017

Note: It seems that error message is only used for:

  • ImmutableQueue.Peek()
  • ImmutableQueue.PeekRef()
  • ImmutableStack.Peek()
  • ImmutableStack.PeekRef() https://github.com/dotnet/corefx/search?q=InvalidEmptyOperation&unscoped_q=InvalidEmptyOperation

jnyrup avatar Aug 20 '18 06:08 jnyrup

The code base I am working with is business code from our company which unfortunately cannot be made public. I can do some digging if you give me some hints how I can get more information about this exception.

FantasyTeddy avatar Aug 20 '18 06:08 FantasyTeddy

I have the same issue, my repository is OS:

https://github.com/csoltenborn/GoogleTestAdapter

See build instructions in the Wiki...

csoltenborn avatar Oct 06 '18 07:10 csoltenborn

@csoltenborn is this still an issue?

Meir017 avatar May 27 '23 21:05 Meir017

Sorry, can't comment on that - I moved on to different things...

Meir Blachman @.***> schrieb am So., 28. Mai 2023, 04:18:

@csoltenborn https://github.com/csoltenborn is this still an issue?

— Reply to this email directly, view it on GitHub https://github.com/fluentassertions/fluentassertions.analyzers/issues/78#issuecomment-1565686856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACWCQDYMQDV6LZOIYAKJFTXIJVUDANCNFSM4FQGJHEQ . You are receiving this because you were mentioned.Message ID: @.*** com>

csoltenborn avatar May 28 '23 05:05 csoltenborn