public static void Main(string[] args)
        {
            try
            {
                //TODO: Use a proper parser for the commands

                if (args.Length <= 0)
                {
                    return;
                }

                var startTime = DateTime.Now;

                var fileName = args[0];
                var fileInfo = new FileInfo(fileName);

                //NOTE: This could be configurable via the CLI at some point
                var report = new AnalyzerReport();

                if (args.Length > 1 && AvailableExporters.ContainsKey(args[1]))
                {
                    var exporterInstance = Activator.CreateInstance(AvailableExporters[args[1]]);
                    report.AddExporter(exporterInstance as IAnalyzerExporter);
                }
                else
                {
                    //It's generally a good idea to make sure that the Console Exporter is last since it is interactive
                    report.AddExporter(new JsonAnalyzerExporter());
                    report.AddExporter(new ConsoleAnalyzerExporter());
                }



                report.InitializeReport(fileInfo);

                var tasks = new List <Task>();
                if (fileInfo.Exists)
                {
                    var solutionAnalyzer = new SolutionAnalyzer();
                    var analyzeTask      = solutionAnalyzer.LoadAnadAnalyzeProject(fileInfo, report);
                    tasks.Add(analyzeTask);
                }

                Task.WaitAll(tasks.ToArray());

                var endTime  = DateTime.Now;
                var duration = endTime - startTime;

                report.FinalizeReport(duration);
            }
            catch (Exception generalException)
            {
                Console.WriteLine("There was an exception running the analysis");
                Console.WriteLine(generalException.ToString());
            }
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            try
            {
                if (args.Length <= 0)
                {
                    return;
                }

                var startTime = DateTime.Now;

                var fileName = args[0];
                var fileInfo = new FileInfo(fileName);

                //NOTE: This could be configurable via the CLI at some point
                var report = new AnalyzerReport();
                report.AddExporter(new ConsoleAnalyzerExporter());
                report.AddExporter(new JsonAnalyzerExporter());


                report.InitializeReport(fileInfo);

                var tasks = new List <Task>();
                if (fileInfo.Exists)
                {
                    var solutionAnalyzer = new SolutionAnalyzer();
                    var analyzeTask      = solutionAnalyzer.LoadAnadAnalyzeProject(fileInfo, report);
                    tasks.Add(analyzeTask);
                }

                Task.WaitAll(tasks.ToArray());

                var endTime  = DateTime.Now;
                var duration = endTime - startTime;

                report.FinalizeReport(duration);

                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
            catch (Exception generalException)
            {
                Console.WriteLine("There was an exception running the analysis");
                Console.WriteLine(generalException.ToString());
            }
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            try
            {
                var options = new Options();
                var isValid = CommandLine.Parser.Default.ParseArgumentsStrict(args, options);

                if (isValid == false || options.ProjectFile == null)
                {
                    return;
                }

                var unityVersionResolver = new UnityVersionResolver();
                options.Version = unityVersionResolver.ResolveVersion(options);

                var startTime = DateTime.Now;

                var fileName = options.ProjectFile;
                var fileInfo = new FileInfo(fileName);

                //NOTE: This could be configurable via the CLI at some point
                var report = new AnalyzerReport();

                if (options.Exporters != null)
                {
                    foreach (var exporter in options.Exporters)
                    {
                        if (AvailableExporters.ContainsKey(exporter))
                        {
                            var exporterInstance = Activator.CreateInstance(AvailableExporters[exporter]);
                            report.AddExporter(exporterInstance as IAnalyzerExporter);
                        }
                    }
                }

                if (report.GetExporterCount() == 0)
                {
                    //It's generally a good idea to make sure that the Console Exporter is last since it is interactive
                    report.AddExporter(new JsonAnalyzerExporter(options));
                    report.AddExporter(new ConsoleAnalyzerExporter(options));
                }

                report.InitializeReport(options);

                var tasks = new List <Task>();
                if (fileInfo.Exists)
                {
                    FileInfo configFileInfo = null;

                    if (options.ConfigurationFile != null)
                    {
                        configFileInfo = new FileInfo(options.ConfigurationFile);
                    }

                    var solutionAnalyzer = new SolutionAnalyzer();
                    var analyzeTask      = solutionAnalyzer.LoadAndAnalyzeProjectAsync(fileInfo, configFileInfo, report);
                    tasks.Add(analyzeTask);
                }

                Task.WaitAll(tasks.ToArray());

                var endTime  = DateTime.Now;
                var duration = endTime - startTime;

                report.FinalizeReport(duration);
            }
            catch (Exception generalException)
            {
                Console.WriteLine("There was an exception running the analysis");
                Console.WriteLine(generalException.ToString());
            }
        }