Beispiel #1
0
        /// <summary>
        /// Gets the short name of a member, without the preceding interface qualifier.
        /// </summary>
        /// <param name="handle">The handle of the name.</param>
        /// <returns>The short name.</returns>
        public string ShortName(StringHandle handle)
        {
            var str = MdReader.GetString(handle);

            if (str.EndsWith(".ctor"))
            {
                return(".ctor");
            }
            if (str.EndsWith(".cctor"))
            {
                return(".cctor");
            }
            var dot = str.LastIndexOf('.');

            return(dot == -1 ? str : str.Substring(dot + 1));
        }
Beispiel #2
0
 /// <summary>
 /// Gets the string for a string handle.
 /// </summary>
 /// <param name="h">The string handle.</param>
 /// <returns>The string.</returns>
 public string GetString(StringHandle h) => MdReader.GetString(h);
        public Context(Extractor extractor, TrapWriter trapWriter, string assemblyPath, bool extractPdbs)
            : base(extractor, trapWriter)
        {
            this.AssemblyPath    = assemblyPath;
            stream               = File.OpenRead(assemblyPath);
            PeReader             = new PEReader(stream, PEStreamOptions.PrefetchEntireImage);
            MdReader             = PeReader.GetMetadataReader();
            TypeSignatureDecoder = new Entities.TypeSignatureDecoder(this);

            globalNamespace            = new Lazy <Entities.Namespace>(() => Populate(new Entities.Namespace(this, "", null)));
            systemNamespace            = new Lazy <Entities.Namespace>(() => Populate(new Entities.Namespace(this, "System")));
            genericHandleFactory       = new CachedFunction <IGenericContext, Handle, IExtractedEntity>(CreateGenericHandle);
            namespaceFactory           = new CachedFunction <StringHandle, Entities.Namespace>(n => CreateNamespace(MdReader.GetString(n)));
            namespaceDefinitionFactory = new CachedFunction <NamespaceDefinitionHandle, Entities.Namespace>(CreateNamespace);
            sourceFiles     = new CachedFunction <PDB.ISourceFile, Entities.PdbSourceFile>(path => new Entities.PdbSourceFile(this, path));
            folders         = new CachedFunction <PathTransformer.ITransformedPath, Entities.Folder>(path => new Entities.Folder(this, path));
            sourceLocations = new CachedFunction <PDB.Location, Entities.PdbSourceLocation>(location => new Entities.PdbSourceLocation(this, location));

            defaultGenericContext = new EmptyContext(this);

            if (extractPdbs)
            {
                Pdb = PDB.PdbReader.Create(assemblyPath, PeReader);
                if (Pdb is not null)
                {
                    Extractor.Logger.Log(Util.Logging.Severity.Info, string.Format("Found PDB information for {0}", assemblyPath));
                }
            }
        }