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)); }
private static void SetupSignatureReferences(INameService service, ICollection <ModuleDefMD> modules, ModuleDef module, TypeSig typeSig) { var asTypeRef = typeSig.TryGetTypeRef(); if (asTypeRef != null) { SetupTypeReference(service, modules, module, asTypeRef); } }
/// <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 corLibTypeSig) { return(TryRelocateCorLibTypeSig(corLibTypeSig)); } if (typeSig is GenericInstSig genericInstSig) { return(TryRelocateGeneric(genericInstSig)); } //if (typeSig is PtrSig) // return null; if (typeSig is ByRefSig byRefSig) { return(TryRelocateByRef(byRefSig)); } if (typeSig is ArraySig arraySig) { return(TryRelocateArray(arraySig)); } if (typeSig is SZArraySig szArraySig) { return(TryRelocateSZArray(szArraySig)); } if (typeSig is GenericVar) { return(null); // TODO constraints } if (typeSig is GenericMVar) { return(null); // TODO constraints } if (typeSig is ClassOrValueTypeSig) { var typeRef = typeSig.TryGetTypeRef(); var typeDefOrRef = typeRef != null?TryRelocateTypeRef(typeRef) : TryRelocateTypeDefOrRef(typeSig.ToTypeDefOrRef()); if (typeDefOrRef == null) { return(null); } if (typeSig is ValueTypeSig) { return(new ValueTypeSig(typeDefOrRef)); } return(typeDefOrRef.ToTypeSig()); } if (typeSig is CModOptSig cModOptSig) { var next = TryRelocateTypeSig(cModOptSig.Next); var modifier = TryRelocateTypeDefOrRef(cModOptSig.Modifier); if (next == null && modifier == null) { return(null); } return(new CModOptSig(modifier ?? cModOptSig.Modifier, next ?? cModOptSig.Next)); } if (typeSig is CModReqdSig cModReqdSig) { var next = TryRelocateTypeSig(cModReqdSig.Next); var modifier = TryRelocateTypeDefOrRef(cModReqdSig.Modifier); if (next == null && modifier == null) { return(null); } return(new CModReqdSig(modifier ?? cModReqdSig.Modifier, next ?? cModReqdSig.Next)); } if (typeSig is FnPtrSig) { return(null); // TODO } if (typeSig is PtrSig) { var next = TryRelocateTypeSig(typeSig.Next); return(next != null ? new PtrSig(next) : null); } if (typeSig is PinnedSig) { var next = TryRelocateTypeSig(typeSig.Next); return(next != null ? new PinnedSig(next) : null); } throw new InvalidOperationException($"type {typeSig.GetType()} not supported (MoFo)"); }