TypeDelegator equality inconsistency?
See the question and my original answer on StackOverflowEqualityComparer<T>
defauls to the object.Equals method, so the 1) and 2) cases are equivalent to 5) and 6).
I don't see why these comparison should be consistent by default. The true cases happen because System.Type
equality implementation is based on the UnderlyingSystemType
property. So, you could override Equals(object) and Equals(Type) - BTW, virtual only on Framework 4 -, but that wouldn't fix case 3).
So, what you can do to make sure it is consistent is this:
class MyType : TypeDelegator
{
public MyType(Type parent)
: base(parent)
{
}
public override Type UnderlyingSystemType
{
get
{
return this;
}
}
}
With this implementation, all cases will report false, which is consistent, but I'm unsure about the side effects... I suppose it depends on what your code does eventually.