I need to generate a series of "defaults" for unknown object types with unique hash codes. (Could be structs or a class with overridden GetHashCode such that it's default construction always returns the same hash.)
To handle most such cases, I use reflection to find numeric fields / properties that I can sequence. So for example, if I can find a double field, I can just keep returning new objects with different values for that field that will generally change the hash.
So how to form that value sequence? At first I thought I just needed to stick to the range of integer resolution and could just keep adding 1.0 each iteration. Based on this answer, I choose a range of -1E50 to 1E50. But it turns out Double.GetHashCode returns the same hash for -1E50 and (-1E50 + 1.0). Reducing the range way down to -1E15 to 1E15 seems to fix it, but I still don't know if what I'm doing is safe. (I don't need anywhere near that big a range, but I do need to know I won't get collisions.)
So my question is, what range of double values can I use (incrementing by 1.0 or some other amount each time) to guarantee different hash results? Does this answer change for float or other numeric types?