NightOwl888 commented on code in PR #1128: URL: https://github.com/apache/lucenenet/pull/1128#discussion_r1953345464
########## src/Lucene.Net/Support/ConcurrentHashSet.cs: ########## @@ -42,7 +43,8 @@ namespace Lucene.Net.Support /// concurrently from multiple threads. /// </remarks> [DebuggerDisplay("Count = {Count}")] - internal class ConcurrentHashSet<T> : ISet<T>, IReadOnlyCollection<T>, ICollection<T> + internal class ConcurrentHashSet<T> : ISet<T>, IReadOnlyCollection<T> + where T : notnull Review Comment: Looks like all of the warnings are because `IComparer<T>.GetHashCode()` doesn't allow `null`. This can be patched by creating a wrapper method. In other collections, `null` always corresponds to the hash code 0. ```c# [MethodImpl(MethodImplOptions.AggressiveInlining)] private int GetItemHashCode(T item) => item is not null ? _comparer.GetHashCode(item) : 0; ``` Do note that the nullability constraint doesn't match any of the BCL implementations, which return 0 for `null` rather than throwing. But doing it this way would future-proof it for any 3rd party `IEqualityComparer<T>` implementations, as well. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org