public MethodSig GetMethodSig() { var mod = Module; var mdi = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>(); if (mdi == null) { return(null); } return(MetaDataUtils.GetMethodSignature(mdi, Token)); }
/// <summary> /// Gets all argument and local types /// </summary> /// <param name="argTypes">Gets updated with all argument types. If there's a hidden this /// parameter, it's the first type. This type can be null. If it's not null, ignore any /// <see cref="ClassSig"/> since it might still be a value type</param> /// <param name="localTypes">Gets updated with all local types</param> /// <returns></returns> public bool GetArgAndLocalTypes(out List <TypeSig> argTypes, out List <TypeSig> localTypes) { argTypes = new List <TypeSig>(); localTypes = new List <TypeSig>(); var func = Function; if (func == null) { return(false); } var module = func.Module; if (module == null) { return(false); } var mdi = module.GetMetaDataInterface <IMetaDataImport>(); var methodSig = MetaDataUtils.GetMethodSignature(mdi, func.Token); if (methodSig != null) { if (methodSig.HasThis) { argTypes.Add(GetThisType(func)); } argTypes.AddRange(methodSig.Params); if (methodSig.ParamsAfterSentinel != null) { argTypes.AddRange(methodSig.ParamsAfterSentinel); } } uint localVarSigTok = func.LocalVarSigToken; if ((localVarSigTok & 0x00FFFFFF) != 0) { var localSig = MetaDataUtils.ReadCallingConventionSig(mdi, localVarSigTok) as LocalSig; if (localSig != null) { localTypes.AddRange(localSig.Locals); } } return(true); }
public MethodSig GetMethodSig() => MetaDataUtils.GetMethodSignature(Module?.GetMetaDataInterface <IMetaDataImport>(), Token);