TypeSig GetThisType(CorFunction func) { if (func == null) { return(null); } var funcClass = func.Class; var mod = funcClass == null ? null : funcClass.Module; var mdi = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>(); if (mdi == null) { return(null); } int numTypeGenArgs = MetaDataUtils.GetCountGenericParameters(mdi, funcClass.Token); var genTypeArgs = this.TypeParameters.Take(numTypeGenArgs).ToArray(); var td = DebugSignatureReader.CreateTypeDef(mdi, funcClass.Token); // Assume it's a class for now. The code should ignore ClassSig and just use the TypeDef var sig = new ClassSig(td); if (genTypeArgs.Length == 0) { return(sig); } var genArgs = new List <TypeSig>(genTypeArgs.Length); for (int i = 0; i < genTypeArgs.Length; i++) { genArgs.Add(new GenericVar(i)); } return(new GenericInstSig(sig, genArgs)); }
static TypeSig GetFieldTypeSig(IMetaDataImport mdi, uint token) { var buf = MDAPI.GetFieldSignatureBlob(mdi, token); if (buf == null) { return(null); } var sig = new DebugSignatureReader().ReadSignature(mdi, buf) as FieldSig; return(sig?.Type); }
static TypeSig GetFieldTypeSig(IMetaDataImport mdi, uint token) { var buf = GetFieldSignature(mdi, token); if (buf == null) return null; var sig = new DebugSignatureReader().ReadSignature(mdi, buf) as FieldSig; return sig == null ? null : sig.Type; }