Esempio n. 1
0
        public void Populate()
        {
            ProcessSourceLink();

            var d2s = new Dictionary <Document, SourceFile>();

            SourceFile FindSource(Document doc)
            {
                if (doc == null)
                {
                    return(null);
                }

                if (d2s.TryGetValue(doc, out SourceFile source))
                {
                    return(source);
                }

                var src = new SourceFile(this, sources.Count, doc, GetSourceLinkUrl(doc.Url));

                sources.Add(src);
                d2s[doc] = src;
                return(src);
            };

            foreach (TypeDefinition type in image.GetTypes())
            {
                var typeInfo = new TypeInfo(this, type);
                typesByName[type.FullName] = typeInfo;

                foreach (MethodDefinition method in type.Methods)
                {
                    foreach (SequencePoint sp in method.DebugInformation.SequencePoints)
                    {
                        SourceFile source     = FindSource(sp.Document);
                        var        methodInfo = new MethodInfo(this, method, source);
                        methods[method.MetadataToken.RID] = methodInfo;
                        if (source != null)
                        {
                            source.AddMethod(methodInfo);
                        }

                        typeInfo.Methods.Add(methodInfo);
                    }
                }
            }
        }
Esempio n. 2
0
        private void Populate()
        {
            var d2s = new Dictionary <int, SourceFile>();

            SourceFile FindSource(DocumentHandle doc, int rowid, string documentName)
            {
                if (d2s.TryGetValue(rowid, out SourceFile source))
                {
                    return(source);
                }

                var src = new SourceFile(this, sources.Count, doc, GetSourceLinkUrl(documentName), documentName);

                sources.Add(src);
                d2s[rowid] = src;
                return(src);
            };

            foreach (DocumentHandle dh in asmMetadataReader.Documents)
            {
                var document = asmMetadataReader.GetDocument(dh);
            }

            if (pdbMetadataReader != null)
            {
                ProcessSourceLink();
            }

            foreach (TypeDefinitionHandle type in asmMetadataReader.TypeDefinitions)
            {
                var typeDefinition = asmMetadataReader.GetTypeDefinition(type);

                var typeInfo = new TypeInfo(this, type, typeDefinition);
                TypesByName[typeInfo.FullName] = typeInfo;
                TypesByToken[typeInfo.Token]   = typeInfo;
                if (pdbMetadataReader != null)
                {
                    foreach (MethodDefinitionHandle method in typeDefinition.GetMethods())
                    {
                        var methodDefinition = asmMetadataReader.GetMethodDefinition(method);
                        if (!method.ToDebugInformationHandle().IsNil)
                        {
                            var methodDebugInformation = pdbMetadataReader.GetMethodDebugInformation(method.ToDebugInformationHandle());
                            if (!methodDebugInformation.Document.IsNil)
                            {
                                var        document     = pdbMetadataReader.GetDocument(methodDebugInformation.Document);
                                var        documentName = pdbMetadataReader.GetString(document.Name);
                                SourceFile source       = FindSource(methodDebugInformation.Document, asmMetadataReader.GetRowNumber(methodDebugInformation.Document), documentName);
                                var        methodInfo   = new MethodInfo(this, method, asmMetadataReader.GetRowNumber(method), source, typeInfo, asmMetadataReader, pdbMetadataReader);
                                methods[asmMetadataReader.GetRowNumber(method)] = methodInfo;

                                if (source != null)
                                {
                                    source.AddMethod(methodInfo);
                                }

                                typeInfo.Methods.Add(methodInfo);
                            }
                        }
                    }
                }
            }
        }