NBMsgPack071: UseComparerAttribute member name must point to a valid property
When UseComparerAttribute specifies a member name, it must point to a public property on the specified type.
Example violation
[GenerateShape]
public partial class MyType
{
[UseComparer(typeof(MyComparerProvider), "Comparer")]
public HashSet<string> MyHashSet { get; set; } = new();
}
internal class MyComparerProvider
{
private static IEqualityComparer<string> Comparer => StringComparer.OrdinalIgnoreCase;
}
Resolution
Ensure the member name points to a public property:
[GenerateShape]
public partial class MyType
{
[UseComparer(typeof(MyComparerProvider), nameof(MyComparerProvider.Comparer))]
public HashSet<string> MyHashSet { get; set; } = new(MyComparerProvider.Comparer);
}
internal class MyComparerProvider
{
public static IEqualityComparer<string> Comparer => StringComparer.OrdinalIgnoreCase;
}