예제 #1
0
        private IntermediateModel BuildResultModelWithoutNavigation(ResultForAssembly result)
        {
            var options = this.GetOptions(result);

            var model = new HtmlResultModel(result.Tables)
            {
                Title         = options.PageTitle,
                HtmlBeforeAll = this.GetResource(result.Assembly, "BeforeAll.html"),
                HtmlAfterAll  = this.GetResource(result.Assembly, "AfterAll.html"),
                TotalVisible  = !((bool?)options.HideTotal ?? false)
            };
            var intermediate = new IntermediateModel {
                FinalModel       = model,
                LinkTitle        = options.LinkTitle,
                TemplateFileName = ResultTemplateFileName,
                OutputFileName   = result.OutputNamePrefix + ".html"
            };

            AddSectionsFromHtml(intermediate, model.HtmlBeforeAll);
            foreach (var table in result.Tables)
            {
                var id = this.GenerateTableId(table);
                model.TableIdMap.Add(table, id);
                intermediate.Sections.Add(new Section {
                    Id = id, DisplayName = table.DisplayName
                });
            }
            AddSectionsFromHtml(intermediate, model.HtmlAfterAll);

            return(intermediate);
        }
예제 #2
0
        private void Write(DirectoryInfo outputDirectory, ResultForAssembly result)
        {
            var tableList = result.Tables.ToArray();

            var general = tableList.First(t => t.Key == MetadataKeys.GeneralInfoTable);
            var netFxVersions = tableList.First(t => t.Key == MetadataKeys.NetFxSupportTable);
            var data = tableList[0].Libraries.Select(l => new {
                name = l.Name,
                url = general[l, MetadataKeys.UrlFeature].DisplayUri,
                version = general[l, MetadataKeys.VersionFeature].DisplayValue,
                supports = GetNetFxVersions(l, netFxVersions),
                features = GetAllFeatureData(l, tableList)
            });

            var json = JsonConvert.SerializeObject(data, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            File.WriteAllText(Path.Combine(outputDirectory.FullName, result.OutputNamePrefix + ".json"), json);
        }
예제 #3
0
        private void Write(DirectoryInfo outputDirectory, ResultForAssembly result)
        {
            var tableList = result.Tables.ToArray();

            var general       = tableList.First(t => t.Key == MetadataKeys.GeneralInfoTable);
            var netFxVersions = tableList.First(t => t.Key == MetadataKeys.NetFxSupportTable);
            var data          = tableList[0].Libraries.Select(l => new {
                name     = l.Name,
                url      = general[l, MetadataKeys.UrlFeature].DisplayUri,
                version  = general[l, MetadataKeys.VersionFeature].DisplayValue,
                supports = GetNetFxVersions(l, netFxVersions),
                features = GetAllFeatureData(l, tableList)
            });

            var json = JsonConvert.SerializeObject(data, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            File.WriteAllText(Path.Combine(outputDirectory.FullName, result.OutputNamePrefix + ".json"), json);
        }
예제 #4
0
        private dynamic GetOptions(ResultForAssembly result)
        {
            var optionsString = this.GetResource(result.Assembly, "Options.json");

            return(JsonConvert.DeserializeObject(optionsString.NullIfEmpty() ?? "{}"));
        }
예제 #5
0
        private static void Main(CommandLineArguments args)
        {
            var cache = new LocalPackageCache(Path.GetFullPath(ConfigurationManager.AppSettings["NuGetPackagesPath"]));
            var httpDataProvider = new HttpDataProvider(new DirectoryInfo("HttpCache"));

            var attributeCleaner = new AttributeTextCleaner();
            var sources = new IFeatureTableSource[] {
                new GeneralInfoTableSource(
                    cache,
                    httpDataProvider,
                    new LicenseResolver(httpDataProvider, new Uri(ConfigurationManager.AppSettings["LicensesJsonUrl"]))
                ),
                new NetFxSupportTableSource(cache),
                new FeatureTestTableSource(new FeatureTestRunner(attributeCleaner), attributeCleaner, new ExceptionNormalizer())
            };
            var outputs = new IResultOutput[] {
                new HtmlOutput(new DirectoryInfo(ConfigurationManager.AppSettings["HtmlTemplatesPath"])),
                new JsonOutput()
            };

            var outputDirectory = new DirectoryInfo(args.OutputPath ?? ConfigurationManager.AppSettings["OutputPath"]);
            if (!outputDirectory.Exists)
                outputDirectory.Create();

            var assemblyPaths = GetAssemblyPaths();
            var results = assemblyPaths.Select(path => {
                console.White.Text("Running " + Path.GetFileName(path) + ":");
                try {
                    var assembly = Assembly.LoadFrom(path);

                    var tables = sources.SelectMany(s => s.GetTables(assembly)).ToArray();
                    CalculateTotal(tables.Single(t => t.Key == MetadataKeys.GeneralInfoTable), tables);

                    var outputNamePrefix = assembly.GetName().Name.SubstringAfter(AssemblyNamePrefix);
                    var result = new ResultForAssembly(assembly, tables, outputNamePrefix);

                    console.Green.Line(" OK");
                    return result;
                }
                catch (Exception) {
                    console.Red.Line(" FAIL");
                    throw;
                }
            }).ToArray();

            console.NewLine();
            console.White.Line("Creating outputs:");
            foreach (var output in outputs) {
                output.Write(outputDirectory, results, args.WatchTemplates);
            }

            if (args.WatchTemplates) {
                console.NewLine()
                       .White
                       .Line("Auto-updating outputs if templates change.")
                       .Line("Press [Enter] to stop.");
                Console.ReadLine();
            }

            foreach (var output in outputs) {
                output.Dispose();
            }

            Console.WriteLine();
            console.Green.Line("Completed.");
        }