Esempio n. 1
0
        private static void Main(CommandLineArguments args)
        {
            var cache = new LocalPackageCache(Path.GetFullPath(ConfigurationManager.AppSettings["NuGetPackagesPath"]));
            var httpDataProvider = new HttpDataProvider(new DirectoryInfo("HttpCache"));

            var sources = new IFeatureTableSource[] {
                new GeneralInfoTableSource(
                    cache,
                    httpDataProvider,
                    new LicenseResolver(httpDataProvider, new Uri(ConfigurationManager.AppSettings["LicensesJsonUrl"]))
                ),
                new NetFxSupportTableSource(cache),
                new FeatureTestTableSource(new FeatureTestRunner())
            };
            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 => {
                ConsoleEx.Write(ConsoleColor.White, "Running " + Path.GetFileName(path) + ":");
                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);

                ConsoleEx.WriteLine(ConsoleColor.Green, " OK");
                return result;
            }).ToArray();

            Console.WriteLine();
            ConsoleEx.WriteLine(ConsoleColor.White, "Creating outputs:");
            foreach (var output in outputs) {
                output.Write(outputDirectory, results, args.WatchTemplates);
            }

            if (args.WatchTemplates) {
                Console.WriteLine();
                ConsoleEx.WriteLine(ConsoleColor.White, "Auto-updating outputs if templates change.");
                ConsoleEx.WriteLine(ConsoleColor.White, "Press [Enter] to stop.");
                Console.ReadLine();
            }

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

            Console.WriteLine();
            ConsoleEx.WriteLine(ConsoleColor.Green, "Completed.");
        }
Esempio n. 2
0
 public static void Main(string[] args)
 {
     var parsedArgs = new CommandLineArguments();
     CommandLine.Parser.Default.ParseArgumentsStrict(args, parsedArgs);
     try {
         Main(parsedArgs);
     }
     catch (Exception ex) {
         console.Red.Line(ex);
     }
 }
Esempio n. 3
0
 public static void Main(string[] args)
 {
     var parsedArgs = new CommandLineArguments();
     CommandLine.Parser.Default.ParseArgumentsStrict(args, parsedArgs);
     try {
         Main(parsedArgs);
     }
     catch (Exception ex) {
         ConsoleEx.WriteLine(ConsoleColor.Red, ex);
     }
 }
Esempio n. 4
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.");
        }
 private static IReadOnlyCollection <string> GetAssemblyPaths(CommandLineArguments args)
 {
     return(Directory.GetFiles(".", AssemblyNamePrefix + "*.dll"));
 }