Gets the hash code for an object using a comparer. Correctly handles null.