Пример #1
0
        private IEnumerable<IEnricher> BuildEnrichers()
        {
            var enrichers = new List<IEnricher>();

            XmlDocEnricher docEnricher = new XmlDocEnricher();
            if (this.IncludeBclDocComments.IsPresent)
            {
                string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                string bclDocPath = System.IO.Path.Combine(winPath, @"microsoft.net\framework\",
                                                           string.Format("v{0}.{1}.{2}",
                                                                         Environment.Version.Major,
                                                                         Environment.Version.Minor,
                                                                         Environment.Version.Build),
                                                           @"en\");


                docEnricher.AddPath(bclDocPath);

                bclDocPath = System.IO.Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
                    @"Reference Assemblies\Microsoft\Framework\.NETFramework",
                    string.Format("v{0}.{1}",
                                  Environment.Version.Major,
                                  Environment.Version.Minor));

                docEnricher.AddPath(bclDocPath);
            }

            enrichers.Add(docEnricher);

            if (!string.IsNullOrEmpty(this.NamespaceDocPath))
            {
                var namespaceEnricher = new ExternalNamespaceDocEnricher();
                if (System.IO.Path.IsPathRooted(this.NamespaceDocPath))
                    namespaceEnricher.Load(this.NamespaceDocPath);
                else if (
                    File.Exists(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.Path),
                                                       this.NamespaceDocPath)))
                    namespaceEnricher.Load(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.Path),
                                                                  this.NamespaceDocPath));
                else
                    namespaceEnricher.Load(this.NamespaceDocPath);

                enrichers.Add(namespaceEnricher);
            }

            return enrichers;
        }
Пример #2
0
        public override void Invoke(CompositionContainer container)
        {
            var traceListener = new ConsolidatedConsoleTraceListener
                                {
                                    { TraceSources.GeneratorSource, "Build" },
                                    { TraceSources.AssemblyLoader, "Loader" },
                                    { TraceSources.AssetResolverSource, "Resolver" },
                                };

            using (traceListener)
            {
                this.ConfigureTraceLevels(traceListener);

                DocGenerator gen = new DocGenerator(container);
                gen.AssetFilters.Add(new ComObjectTypeFilter());
                gen.AssetFilters.Add(new CompilerGeneratedFilter());
                if (!this.IncludeNonPublic.IsPresent)
                    gen.AssetFilters.Add(new PublicTypeFilter());

                gen.AssetFilters.Add(new PrivateImplementationDetailsFilter());
                gen.AssetFilters.Add(new DynamicallyInvokableAttributeFilter());
                gen.AssetFilters.Add(new CompilerGeneratedFilter());
                gen.AssetFilters.Add(new LogicalMemberInfoVisibilityFilter());
                gen.AssetFilters.Add(new SpecialNameMemberInfoFilter());

                if (!string.IsNullOrWhiteSpace(this.Filter))
                    gen.AssetFilters.Add(new AssetGlobFilter { Include = this.Filter });

                XmlDocEnricher docEnricher = new XmlDocEnricher();
                gen.Enrichers.Add(docEnricher);


                if (!string.IsNullOrEmpty(this.NamespaceDocPath))
                {
                    var namespaceEnricher = new ExternalNamespaceDocEnricher();
                    if (System.IO.Path.IsPathRooted(this.NamespaceDocPath))
                        namespaceEnricher.Load(this.NamespaceDocPath);
                    else if (
                        File.Exists(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.Path),
                                                           this.NamespaceDocPath)))
                        namespaceEnricher.Load(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.Path),
                                                                      this.NamespaceDocPath));
                    else
                        namespaceEnricher.Load(this.NamespaceDocPath);

                    gen.Enrichers.Add(namespaceEnricher);
                }


                if (!File.Exists(this.Path))
                {
                    Console.WriteLine("File not found: '{0}'", this.Path);
                    return;
                }

                if (this.IncludeBclDocComments.IsPresent)
                {
                    string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                    string bclDocPath = System.IO.Path.Combine(winPath, @"microsoft.net\framework\",
                                                               string.Format("v{0}.{1}.{2}",
                                                                             Environment.Version.Major,
                                                                             Environment.Version.Minor,
                                                                             Environment.Version.Build),
                                                               @"en\");


                    docEnricher.AddPath(bclDocPath);

                    bclDocPath = System.IO.Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
                        @"Reference Assemblies\Microsoft\Framework\.NETFramework",
                        string.Format("v{0}.{1}",
                                      Environment.Version.Major,
                                      Environment.Version.Minor));

                    docEnricher.AddPath(bclDocPath);
                }


                var assemblyName = AssemblyName.GetAssemblyName(this.Path);

                XDocument rawDoc = gen.Generate(this.Path);

                string fileName = System.IO.Path.Combine(this.Output ?? System.IO.Path.GetDirectoryName(this.Path),
                                                         string.Format("{0}_{1}.ldoc",
                                                                       System.IO.Path.GetFileName(this.Path),
                                                                       assemblyName.Version));

                this.Output = System.IO.Path.GetFullPath(fileName);

                if (!Directory.Exists(System.IO.Path.GetDirectoryName(fileName)))
                    Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fileName));

                rawDoc.Save(fileName);

            }

        }