Skip to content

False positive for "Use .Should().OnlyHaveUniqueItems()" #299

Closed
@FantasyTeddy

Description

@FantasyTeddy

Description

The analysis rule FAA0001: Use .Should().OnlyHaveUniqueItems() is triggered for collections that are not actually the same:

// Arrange
var expected = new List<string> {"First"};

// Act
var actual = new List<int> {0};

// Assert
actual.Should().HaveSameCount(expected.Distinct());

Expected behavior:

This code should not trigger the rule about using .OnlyHaveUniqueItems(), since it has a different meaning (consider that expected is passed in, instead of actual).

Actual behavior:

The rule is triggered.

Versions

  • Fluent Assertions Analyzers version: 0.29.1
  • .NET Runtime/Target: .NET 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions