public static PdbCustomDebugInfo Read(ModuleDef module, TypeDef typeOpt, CilBody bodyOpt, GenericParamContext gpContext, Guid kind, ref DataReader reader)
 {
     try {
         var cdiReader = new PortablePdbCustomDebugInfoReader(module, typeOpt, bodyOpt, gpContext, ref reader);
         var cdi       = cdiReader.Read(kind);
         Debug.Assert(cdiReader.reader.Position == cdiReader.reader.Length);
         return(cdi);
     }
     catch (ArgumentException) {
     }
     catch (OutOfMemoryException) {
     }
     catch (IOException) {
     }
     return(null);
 }
コード例 #2
0
        void GetCustomDebugInfos(int token, GenericParamContext gpContext, IList <PdbCustomDebugInfo> result, MethodDef methodOpt, CilBody bodyOpt, out PdbAsyncMethodSteppingInformationCustomDebugInfo asyncStepInfo)
        {
            asyncStepInfo = null;
            var mdToken = new MDToken(token);
            var ridList = pdbMetadata.GetCustomDebugInformationRidList(mdToken.Table, mdToken.Rid);

            if (ridList.Count == 0)
            {
                return;
            }
            var typeOpt = methodOpt?.DeclaringType;

            for (int i = 0; i < ridList.Count; i++)
            {
                var rid = ridList[i];
                if (!pdbMetadata.TablesStream.TryReadCustomDebugInformationRow(rid, out var row))
                {
                    continue;
                }
                var guid = pdbMetadata.GuidStream.Read(row.Kind);
                if (!pdbMetadata.BlobStream.TryCreateReader(row.Value, out var reader))
                {
                    continue;
                }
                Debug.Assert(guid is not null);
                if (guid is null)
                {
                    continue;
                }
                var cdi = PortablePdbCustomDebugInfoReader.Read(module, typeOpt, bodyOpt, gpContext, guid.Value, ref reader);
                Debug.Assert(cdi is not null);
                if (cdi is not null)
                {
                    if (cdi is PdbAsyncMethodSteppingInformationCustomDebugInfo asyncStepInfoTmp)
                    {
                        Debug.Assert(asyncStepInfo is null);
                        asyncStepInfo = asyncStepInfoTmp;
                    }
                    else
                    {
                        result.Add(cdi);
                    }
                }
            }
        }