private static void Execute(CommandLineOptions options) { Console.WriteLine($"Analysing {options.CsprojFile}"); Console.WriteLine($" repeats={options.RepeatCount}"); Console.WriteLine($" outofprocess={options.UseOufOfProcessAnalyzer}"); Console.WriteLine($" verbose={options.IsVerbose}"); Console.WriteLine(); _isVerbose = options.IsVerbose; var directoryPath = Path.GetDirectoryName(options.CsprojFile); if (directoryPath == null) { throw new Exception("DirectoryPath is null."); } var analyzer = CreateAnalyzer(directoryPath, options.UseOufOfProcessAnalyzer); var csProjParser = new CsProjParser(options.CsprojFile); var runTimeSpans = new List <TimeSpan>(); AnalyzerMessageBase[] lastMessages = null; for (var i = 0; i < options.RepeatCount; i++) { if (_isVerbose) { Console.WriteLine(); } Console.WriteLine($"Starting iteration {i + 1}..."); if (_isVerbose) { Console.WriteLine(); } var(runTime, analyzerMessages) = AnalyseCsProj(analyzer, csProjParser); runTimeSpans.Add(runTime); lastMessages = analyzerMessages; } Console.WriteLine(); DumpAnalyzerMessages(lastMessages); Console.WriteLine(); for (var i = 0; i < options.RepeatCount; i++) { Console.WriteLine($"Iteration {i + 1:00} took: {runTimeSpans[i]:mm\\:ss\\.fff}"); } Console.WriteLine(); DumpRunTimes(runTimeSpans); }
AnalyseCsProj(IDependencyAnalyzer dependencyAnalyzer, CsProjParser csProjParser) { var startTime = DateTime.Now; var analyzerMessages = dependencyAnalyzer .AnalyzeProject(csProjParser.SourceFilePaths, csProjParser.ReferencedAssemblyPaths) .ToArray(); var endTime = DateTime.Now; var elapsedTimeSpan = endTime - startTime; return(elapsedTimeSpan, analyzerMessages); }
private static void ValidateProject(CommandLineOptions options) { Console.WriteLine($"Analysing {options.CsprojFile}, repeats={options.RepeatCount}, useSingleFileConfig={options.UseSingleFileConfig} ..."); _isVerbose = options.IsVerbose; var csProjParser = new CsProjParser(options.CsprojFile); var dependencyAnalyzer = CreateDependencyAnalyzer(options); var runTimeSpans = new List <TimeSpan>(); for (var i = 0; i < options.RepeatCount; i++) { runTimeSpans.Add(AnalyseCsProj(dependencyAnalyzer, csProjParser)); } DumpRunTimes(runTimeSpans); }
private static TimeSpan AnalyseCsProj(IDependencyAnalyzer dependencyAnalyzer, CsProjParser csProjParser) { var startTime = DateTime.Now; var illegalDependencies = dependencyAnalyzer.AnalyzeProject(csProjParser.SourceFilePaths, csProjParser.ReferencedAssemblyPaths).ToList(); var endTime = DateTime.Now; var elapsedTimeSpan = endTime - startTime; Console.WriteLine($"Analysis took: {elapsedTimeSpan:mm\\:ss\\.fff}"); DumpIllegalDependencies(illegalDependencies); return(elapsedTimeSpan); }
private static void Execute(CommandLineOptions options) { Console.WriteLine($"Analysing {options.CsprojFile}"); Console.WriteLine($" repeats={options.RepeatCount}"); Console.WriteLine($" useSingleFileConfig={options.UseSingleFileConfig}"); Console.WriteLine($" outofprocess={options.UseOufOfProcessAnalyzer}"); Console.WriteLine($" verbose={options.IsVerbose}"); Console.WriteLine(); _isVerbose = options.IsVerbose; var directoryPath = Path.GetDirectoryName(options.CsprojFile); if (directoryPath == null) { throw new Exception("DirectoryPath is null."); } var configProvider = CreateConfigProvider(directoryPath, options.UseSingleFileConfig); if (configProvider.ConfigState != AnalyzerConfigState.Enabled) { throw new Exception($"ConfigState={configProvider.ConfigState}, ConfigException={configProvider.ConfigException}"); } var analyzer = CreateAnalyzer(configProvider.Config, options.UseOufOfProcessAnalyzer); var csProjParser = new CsProjParser(options.CsprojFile); var runTimeSpans = new List <TimeSpan>(); TypeDependency[] lastIllegalDependencies = null; for (var i = 0; i < options.RepeatCount; i++) { if (_isVerbose) { Console.WriteLine(); } Console.WriteLine($"Starting iteration {i + 1}..."); if (_isVerbose) { Console.WriteLine(); } var(runTime, illegalDependencies) = AnalyseCsProj(analyzer, csProjParser); if (_isVerbose) { Console.WriteLine(GetCacheStatisticsMessage(analyzer)); } runTimeSpans.Add(runTime); lastIllegalDependencies = illegalDependencies; } Console.WriteLine(); DumpIllegalDependencies(lastIllegalDependencies); Console.WriteLine(); for (var i = 0; i < options.RepeatCount; i++) { Console.WriteLine($"Iteration {i + 1:00} took: {runTimeSpans[i]:mm\\:ss\\.fff}"); } Console.WriteLine(); DumpRunTimes(runTimeSpans); }