Use the SigComparer class to compare different metadata entities (types, methods, fields, etc.). It can compare entities against each other or against standard .NET types like System.Type or System.Reflection.MethodBase.
For use in collections like Dictionary<TKey, TValue>, use the provided pre-created equality comparers such as TypeEqualityComparer.Instance or FieldEqualityComparer.Instance.
// Compare two types
TypeRef type1 = ...;
TypeDef type2 = ...;
if (new SigComparer().Equals(type1, type2)) {
Console.WriteLine("They're equal");
}
// Use the type equality comparer in a Dictionary
Dictionary<IType, int> dict = new Dictionary<IType, int>(TypeEqualityComparer.Instance);
TypeDef type1 = ...;
dict.Add(type1, 10);
// Compare a TypeRef with a System.Type
TypeRef type1 = ...;
if (new SigComparer().Equals(type1, typeof(int))) {
Console.WriteLine("They're equal");
}