Table of Contents

NBMsgPack072: UseComparerAttribute must specify a compatible comparer

UseComparerAttribute must specify a type or member that implements IComparer<T> or IEqualityComparer<T> appropriate for the decorated collection.

Example violation

[UseComparer(typeof(NotAComparer))]
public HashSet<string> MyHashSet { get; set; } = new();

Resolution

Specify a type that implements the appropriate comparer interface:

[UseComparer(typeof(StringComparer))]
public HashSet<string> MyHashSet { get; set; } = new(new StringComparer());