// dnlib: See LICENSE.txt for more info using System.IO; using dnlib.DotNet.Pdb.Symbols; using dnlib.IO; namespace dnlib.DotNet.Pdb.Managed { /// /// Creates a instance /// static class SymbolReaderFactory { /// /// Creates a new instance /// /// PDB context /// PDB file stream which is now owned by this method /// A new instance or null. public static SymbolReader Create(PdbReaderContext pdbContext, DataReaderFactory pdbStream) { if (pdbStream is null) return null; try { var debugDir = pdbContext.CodeViewDebugDirectory; if (debugDir is null) return null; if (!pdbContext.TryGetCodeViewData(out var pdbGuid, out uint age)) return null; var pdbReader = new PdbReader(pdbGuid, age); pdbReader.Read(pdbStream.CreateReader()); if (pdbReader.MatchesModule) return pdbReader; return null; } catch (PdbException) { } catch (IOException) { } finally { pdbStream?.Dispose(); } return null; } } }