Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for "Use .Should().HaveSameCount()" #300

Closed
FantasyTeddy opened this issue Jan 23, 2024 · 1 comment · Fixed by #303
Closed

False positive for "Use .Should().HaveSameCount()" #300

FantasyTeddy opened this issue Jan 23, 2024 · 1 comment · Fixed by #303
Labels

Comments

@FantasyTeddy
Copy link

FantasyTeddy commented Jan 23, 2024

Description

The analysis rule FAA0001: Use .Should().HaveSameCount() is triggered for inputs that are actually combined values:

// Arrange
var expectedFirstHalf = new List<int> {0};
var expectedSecondHalf = new List<int> {1};

// Act
var actual = new List<int> {10, 11};

// Assert
actual.Should().HaveCount(expectedFirstHalf.Count() + expectedSecondHalf.Count());

Expected behavior:

Since the input (expectedFirstHalf.Count() + expectedSecondHalf.Count()) is actually a calculated value, the analysis rule should not be triggered.

Actual behavior:

The rule is triggered and the code fix crashes.

Versions

  • Fluent Assertions Analyzers version: 0.29.1
  • .NET Runtime/Target: .NET 8
@Meir017
Copy link
Member

Meir017 commented Jan 24, 2024

@FantasyTeddy Thanks for reporting this!

Meir017 added a commit that referenced this issue Jan 24, 2024
* bugfix: fix analyzer for issue #300

* bugfix: fix issue 299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants