Пример #1
0
        private void Run()
        {
            try
            {
                if (OutputPath != null)
                {
                    if (!Directory.Exists(OutputPath))
                    {
                        Directory.CreateDirectory(OutputPath);
                    }
                }

                using (var assembly = new AssemblyReflector(AssemblyFileName, _logger))
                {
                    var publicApiReferenceFileName = Path.GetFileNameWithoutExtension(AssemblyFileName) + ".html";
                    var publicApiSlashdocFileName  = Path.GetFileNameWithoutExtension(AssemblyFileName) + ".xml";
                    if (OutputPath != null)
                    {
                        publicApiReferenceFileName = Path.Combine(OutputPath, publicApiReferenceFileName);
                        publicApiSlashdocFileName  = Path.Combine(OutputPath, publicApiSlashdocFileName);
                    }

                    var slashdocFileName = Path.ChangeExtension(AssemblyFileName, ".xml");
                    var slashdoc         = new SlashdocDictionary();
                    if (File.Exists(slashdocFileName))
                    {
                        using (var slashdocStream = new FileStream(slashdocFileName, FileMode.Open, FileAccess.Read))
                        {
                            SlashdocProcessor.WritePublicApiSlashdoc(assembly, slashdocStream, publicApiSlashdocFileName);
                        }

                        using (var slashdocStream = new FileStream(slashdocFileName, FileMode.Open, FileAccess.Read))
                        {
                            slashdoc = SlashdocReader.Parse(slashdocStream);
                        }
                    }
                    else
                    {
                        _logger.LogWarning(string.Format(CultureInfo.InvariantCulture, "Could not open slashdoc file '{0}'.", slashdocFileName));
                    }

                    var language = new CSharpSignatureProvider();
                    var title    = string.Format(CultureInfo.InvariantCulture, "{0} public API reference", assembly.SimpleName);
                    using (var apiReferenceWriter = new ApiReferenceHtmlWriter(publicApiReferenceFileName, title, slashdoc, language, _logger))
                    {
                        apiReferenceWriter.EnableMissingSummaryWarnings = EnableMissingSummaryWarnings;
                        apiReferenceWriter.DescribeAssembly(assembly);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }
        }
 private static void DescribeTheSlashdocMappingTestClass(bool enableMissingSummaryWarnings, ILog logger)
 {
     var language = new CSharpSignatureProvider();
     using (var stream = new MemoryStream())
     {
         using (var writer = new ApiReferenceHtmlWriter(stream, false, "Xyz", new SlashdocDictionary(), language, logger))
         {
             writer.EnableMissingSummaryWarnings = enableMissingSummaryWarnings;
             writer.DescribeType(typeof(TestData.Xyz.Foo.SlashdocMappingTestClass), new SlashdocSummaryHtmlFormatter(DummyAssembly, language));
         }
     }
 }
 private static Stream DescribeType(Type type, SlashdocDictionary slashdoc)
 {
     var stream = new MemoryStream();
     var language = new CSharpSignatureProvider();
     using (var writer = new ApiReferenceHtmlWriter(stream, false, "Xyz", slashdoc, language, new Mock<ILog>().Object))
     {
         writer.DescribeType(type, new SlashdocSummaryHtmlFormatter(DummyAssembly, language));
     }
     stream.Seek(0, SeekOrigin.Begin);
     return stream;
 }
Пример #4
0
        private void Run()
        {
            try
            {
                if (OutputPath != null)
                {
                    if (!Directory.Exists(OutputPath))
                    {
                        Directory.CreateDirectory(OutputPath);
                    }
                }

                using (var assembly = new AssemblyReflector(AssemblyFileName, _logger))
                {
                    var publicApiReferenceFileName = Path.GetFileNameWithoutExtension(AssemblyFileName) + ".html";
                    var publicApiSlashdocFileName = Path.GetFileNameWithoutExtension(AssemblyFileName) + ".xml";
                    if (OutputPath != null)
                    {
                        publicApiReferenceFileName = Path.Combine(OutputPath, publicApiReferenceFileName);
                        publicApiSlashdocFileName = Path.Combine(OutputPath, publicApiSlashdocFileName);
                    }

                    var slashdocFileName = Path.ChangeExtension(AssemblyFileName, ".xml");
                    var slashdoc = new SlashdocDictionary();
                    if (File.Exists(slashdocFileName))
                    {
                        using (var slashdocStream = new FileStream(slashdocFileName, FileMode.Open, FileAccess.Read))
                        {
                            SlashdocProcessor.WritePublicApiSlashdoc(assembly, slashdocStream, publicApiSlashdocFileName);
                        }

                        using (var slashdocStream = new FileStream(slashdocFileName, FileMode.Open, FileAccess.Read))
                        {
                            slashdoc = SlashdocReader.Parse(slashdocStream);
                        }
                    }
                    else
                    {
                        _logger.LogWarning(string.Format(CultureInfo.InvariantCulture, "Could not open slashdoc file '{0}'.", slashdocFileName));
                    }

                    var language = new CSharpSignatureProvider();
                    var title = string.Format(CultureInfo.InvariantCulture, "{0} public API reference", assembly.SimpleName);
                    using (var apiReferenceWriter = new ApiReferenceHtmlWriter(publicApiReferenceFileName, title, slashdoc, language, _logger))
                    {
                        apiReferenceWriter.EnableMissingSummaryWarnings = EnableMissingSummaryWarnings;
                        apiReferenceWriter.DescribeAssembly(assembly);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }
        }