Skip to content

CollectionShouldOnlyHaveUniqueItemsByComparer gives invalid code #63

@jnyrup

Description

@jnyrup

Description

CollectionShouldOnlyHaveUniqueItemsByComparer is triggered by this code

var list = new[] { 1, 2, 3 };

list.Select(e => e.ToString())
    .Where(e => e != "")
    .Should()
    .OnlyHaveUniqueItems();

Which turns it into this invalid code, as the Where now tries to compare an int to a string.

var list = new[] { 1, 2, 3 };

list.Where(e => e != "")
    .Should()
    .OnlyHaveUniqueItems(e => e.ToString());

Expected behavior:

The analyzer should not be triggered.

Actual behavior:

The analyzer is triggered.

Versions

Fluent Assertions Analyzers 0.11.2
.NET Framework 4.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions