Exemplo n.º 1
0
        public TypeDocumentation(TypeDefinition typeDefinition, PackageTargetFramework framework, PackageAssemblyXmlDocs xmlDocs,
                                 Lazy <ICSharpCode.Decompiler.CSharp.CSharpDecompiler> decompiler, Lazy <ICSharpCode.Decompiler.CSharp.CSharpDecompiler> idecompiler,
                                 ICSharpCode.Decompiler.CSharp.OutputVisitor.CSharpFormattingOptions format)
        {
            this.xmlDocs        = xmlDocs;
            this.typeDefinition = typeDefinition;
            this.framework      = framework;
            this.decompiler     = decompiler;
            this.idecompiler    = idecompiler;
            this.format         = format;

            SummaryHtml       = "";
            SummaryText       = "";
            DocumentationHtml = "";

            if (xmlDocs != null)
            {
                var tn = typeDefinition.GetXmlName();
                if (xmlDocs.MemberDocs.TryGetValue(tn, out var td))
                {
                    SummaryHtml = XmlToHtml(td.SummaryXml);
                    SummaryText = XmlToText(td.SummaryXml);
                    if (ignoreSummaryTextRe.IsMatch(SummaryHtml))
                    {
                        SummaryHtml = "";
                        SummaryText = "";
                    }
                }
            }

            var w = new StringWriter();

            WriteDocumentation(w);
            DocumentationHtml = w.ToString();
        }
Exemplo n.º 2
0
        public TypeDocumentation(TypeDefinition typeDefinition, PackageAssemblyXmlDocs xmlDocs)
        {
            this.typeDefinition = typeDefinition;

            SummaryText = "";

            if (xmlDocs != null)
            {
                var tn = GetXmlName(typeDefinition);
                if (xmlDocs.MemberDocs.TryGetValue(tn, out var td))
                {
                    SummaryText = td.SummaryText.Trim();
                    if (SummaryText == "To be added.")
                    {
                        SummaryText = "";
                    }
                }
            }
        }
Exemplo n.º 3
0
        async Task ReadAsync(HttpClient httpClient, string packageUri)
        {
            this.Client = httpClient;
            var entries = await ReadEntriesAsync(httpClient, packageUri);

            TargetFrameworks.Clear();
            Content.Clear();
            Tools.Clear();
            Entry nuspecEntry = null;

            foreach (var e in entries.Where(x => Path.GetFileName(x.FullName) != "_._").OrderBy(x => x.FullName))
            {
                var n       = e.FullName;
                var isBuild = n.StartsWith("build/", StringComparison.InvariantCultureIgnoreCase);
                var isLib   = n.StartsWith("lib/", StringComparison.InvariantCultureIgnoreCase);
                if ((isBuild || isLib) && (n.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
                                           n.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase) ||
                                           n.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)))
                {
                    var    parts = n.Split('/', StringSplitOptions.RemoveEmptyEntries);
                    string tfm;
                    if (parts.Length >= 3)
                    {
                        tfm = Uri.UnescapeDataString(parts[1].Trim().ToLowerInvariant());
                    }
                    else
                    {
                        tfm = "net";
                    }
                    var tf = TargetFrameworks.FirstOrDefault(x => x.Moniker == tfm);
                    if (tf == null)
                    {
                        tf = new PackageTargetFramework(this, httpClient)
                        {
                            Moniker = tfm,
                        };
                        TargetFrameworks.Add(tf);
                    }
                    if (n.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase))
                    {
                        var docs = new PackageAssemblyXmlLanguageDocs(e);
                        if (string.IsNullOrEmpty(docs.Error))
                        {
                            // System.Console.WriteLine(docs.AssemblyName);
                            if (!tf.AssemblyXmlDocs.TryGetValue(docs.AssemblyName, out var allLanguageDocs))
                            {
                                allLanguageDocs = new PackageAssemblyXmlDocs(docs.AssemblyName);
                                tf.AssemblyXmlDocs[docs.AssemblyName] = allLanguageDocs;
                            }
                            allLanguageDocs.AddLanguage(docs.LanguageCode, docs);
                        }
                    }
                    else if (isBuild)
                    {
                        tf.BuildAssemblies.Add(new PackageAssembly(e, tf));
                    }
                    else
                    {
                        tf.Assemblies.Add(new PackageAssembly(e, tf));
                    }
                }
                else if (n.EndsWith(".nuspec", StringComparison.InvariantCultureIgnoreCase))
                {
                    nuspecEntry = e;
                }
                else if (n.StartsWith("content/", StringComparison.InvariantCultureIgnoreCase))
                {
                    Content.Add(new PackageFile(e));
                }
                else if (n.StartsWith("tools/", StringComparison.InvariantCultureIgnoreCase))
                {
                    Tools.Add(new PackageFile(e));
                }
                else
                {
                    // System.Console.WriteLine(e);
                }
            }
            if (nuspecEntry != null)
            {
                ReadNuspec(nuspecEntry);
            }
            TargetFrameworks.Sort((a, b) => string.Compare(a.Moniker, b.Moniker, StringComparison.Ordinal));
        }
Exemplo n.º 4
0
        void Read(MemoryStream bytes, HttpClient httpClient)
        {
            SizeInBytes = bytes.Length;
            Archive     = new ZipArchive(bytes, ZipArchiveMode.Read);
            TargetFrameworks.Clear();
            ZipArchiveEntry nuspecEntry = null;

            foreach (var e in Archive.Entries.Where(x => x.Name != "_._").OrderBy(x => x.FullName))
            {
                var n       = e.FullName;
                var isBuild = n.StartsWith("build/", StringComparison.InvariantCultureIgnoreCase);
                var isLib   = n.StartsWith("lib/", StringComparison.InvariantCultureIgnoreCase);
                if ((isBuild || isLib) && (n.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
                                           n.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase) ||
                                           n.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)))
                {
                    var    parts = n.Split('/', StringSplitOptions.RemoveEmptyEntries);
                    string tfm;
                    if (parts.Length >= 3)
                    {
                        tfm = Uri.UnescapeDataString(parts[1].Trim().ToLowerInvariant());
                    }
                    else
                    {
                        tfm = "net";
                    }
                    var tf = TargetFrameworks.FirstOrDefault(x => x.Moniker == tfm);
                    if (tf == null)
                    {
                        tf = new PackageTargetFramework(this, httpClient)
                        {
                            Moniker = tfm,
                        };
                        TargetFrameworks.Add(tf);
                    }
                    if (n.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase))
                    {
                        var docs = new PackageAssemblyXmlDocs(e);
                        if (string.IsNullOrEmpty(docs.Error))
                        {
                            // System.Console.WriteLine(docs.AssemblyName);
                            tf.AssemblyXmlDocs[docs.AssemblyName] = docs;
                        }
                    }
                    else if (isBuild)
                    {
                        tf.BuildAssemblies.Add(new PackageAssembly(e, tf));
                    }
                    else
                    {
                        tf.Assemblies.Add(new PackageAssembly(e, tf));
                    }
                }
                else if (n.EndsWith(".nuspec", StringComparison.InvariantCultureIgnoreCase))
                {
                    nuspecEntry = e;
                }
                else if (n.StartsWith("content/", StringComparison.InvariantCultureIgnoreCase))
                {
                    Content.Add(new PackageFile(e));
                }
                else if (n.StartsWith("tools/", StringComparison.InvariantCultureIgnoreCase))
                {
                    Tools.Add(new PackageFile(e));
                }
                else
                {
                    // System.Console.WriteLine(e);
                }
            }
            if (nuspecEntry != null)
            {
                ReadNuspec(nuspecEntry);
            }
            TargetFrameworks.Sort((a, b) => string.Compare(a.Moniker, b.Moniker, StringComparison.Ordinal));
        }