Collections like Lists are cannot be used with HashCode.Combine(collection);
Type of issue
Missing information
Description
I spent a good deal of time trying to understand why my Distinct operations were not working for a newly created Type. It turns out that the HashCode.Combine(collection); does not work, it works fine when the instances passed in are not collections, but the documentation doesn't say that clearly. In my opinion there should be a type check in the method itself as this makes the code very dangerous as only at runtime the issue can be discovered. I found it just because I was testing most of the equality features around my new type.
I'd be happy to know if I am missing something
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.hashcode.combine?view=net-8.0#system-hashcode-combine-1(-0)
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/HashCode.xml
Document Version Independent Id
4b23ab47-87c7-32b1-a0ca-9c13d5ec93e5
Article author
@dotnet-bot
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @dotnet/area-system-runtime