/// <summary> /// Relocates the <see cref="TypeSig"/>. /// </summary> /// <param name="typeSig">The type sig.</param> /// <returns>A new type if it was relocated, null otherwise</returns> /// <exception cref="InvalidOperationException">If signature is of unknown type.</exception> public virtual TypeSig TryRelocateTypeSig(TypeSig typeSig) { if (typeSig == null) return null; if (typeSig is CorLibTypeSig) return null; if (typeSig is GenericInstSig) return TryRelocateGeneric((GenericInstSig)typeSig); if (typeSig is PtrSig) return null; if (typeSig is ByRefSig) return TryRelocateByRef((ByRefSig)typeSig); if (typeSig is ArraySig) return TryRelocateArray((ArraySig)typeSig); if (typeSig is SZArraySig) return TryRelocateSZArray((SZArraySig)typeSig); if (typeSig is GenericVar) return null; // TODO constraints if (typeSig is GenericMVar) return null; // TODO constraints if (typeSig is ValueTypeSig || typeSig is ClassSig) { var typeRef = typeSig.TryGetTypeRef(); if (typeRef != null) return TryRelocateTypeRef(typeRef); var typeDefOrRef = TryRelocateTypeDefOrRef(typeSig.ToTypeDefOrRef()); return typeDefOrRef?.ToTypeSig(); } throw new InvalidOperationException(); }
public bool TypeEquals(TypeSig td, Type t) { if (!AssemblyEquals(td.Module.Assembly, t.Assembly) || td.FullName != t.FullName) return false; return TypeEquals(td.TryGetTypeRef(), t); }