I'm working on writing a compiler for a language running on .net and one of the things I would like it to do is to automatically generate the GetHashCode method, but I have several questions:
- Is this possible, does the compiler know enough about the type(s) involved to do a reasonable job implementing the method?
- Should I do this for value types, reference types, or both?
- What is a reasonable GetHashCode algorithm for the compiler to generate which includes support for null properties and so forth?
- Has this been done in another language/compiler that I can look at?
- If this isn't possible or is a really bad idea, why?
Thanks