using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
public static void Main()
var listOfClaimPaths = new List<ClaimPath>
var distinctList = listOfClaimPaths.Distinct();
Console.WriteLine("nothing happened 1");
Console.WriteLine(distinctList.Count());
var distinctList2 = listOfClaimPaths.Distinct(new ClaimPathComparer());
Console.WriteLine("nothing happened 2");
Console.WriteLine(distinctList2.Count());
public record class ClaimIdentifier(string Value);
public class ClaimPath : IEquatable<ClaimPath>
public IEnumerable<ClaimIdentifier> Identifiers { get; private set; } = new List<ClaimIdentifier>();
public bool Starred { get; private set; }
public ClaimPath(IEnumerable<ClaimIdentifier> identifiers, bool starred)
public ClaimPath(string value)
public override bool Equals(object obj)
return Equals(obj as ClaimPath);
public bool Equals(ClaimPath other)
return Identifiers.SequenceEqual(other.Identifiers);
public override int GetHashCode()
return HashCode.Combine(Identifiers);
public override string ToString()
var path = string.Join("/", Identifiers.Select(v => v.Value));
return Starred ? $"{path}/*" : path;
public class ClaimPathComparer : IEqualityComparer<ClaimPath>
public ClaimPathComparer()
Console.WriteLine("Created comparer");
public bool Equals(ClaimPath claimPath1, ClaimPath claimPath2)
Console.WriteLine("compared");
if (claimPath1 == null || claimPath2 == null)
return claimPath1.Equals(claimPath2);
public int GetHashCode([DisallowNull] ClaimPath obj)
Console.WriteLine("hashcode");
return obj.GetHashCode();