I would say that this is a bug in Resharper. The HashSet<T> created to handle null values. This can be seen from consideration of the code in the reflector. In particular, the InternalGetHashCode method, which has an explicit check for null and provides a default hash code of 0.
In the case where this could potentially cause a problem, for user instances of IEqualityComparer<T> , a HashSet<T> is passed that do not take into account null values. I would say this is pretty rare, but since null checks are part of the standard equality pattern for reference types in .Net.
Note. To be clear, I certainly do not encourage people to add null to their collection. I would actually encourage the opposite. Just pointing out that for some reason HashSet<T> explicitly allows this scenario.
source share