How does the Type.Equals(Type) compare types to know if they are the same or not?
The original question was being confused because of what I had here in the body as what I thought would direct the question. Forget that part. The question is in the title.
EDIT: Lasse V. Larksen posed my question best:
“What makes up the identity of a .NET type”…”If I declare the exact same type, down to the namespace, in two different projects/assemblies, .NET consider them different, why?”
ECMA-335 Common Language Infrastructure Partitions I and II dictate that each type will be known by a given type signature. It states how IL represents this signature and how the Virtual Execution System should interpret the signature, but it leaves how a conformant runtime implementation must actually implement this type signature up to the implementation (as far as I can tell).
However, to your question, regardless of how
UnderlyingSystemTypeis actually implemented it will correlate to a unique reference using the containing:Partition II has the physical metadata for a
TypeDef(section 22.37) which encodes this information.Partition III contains the IL which represents loading a metadata token, known as a
RuntimeHandleonto the stack. There are different handles for types, methods, and fields depending on the token given to the IL instructions.