static void Main(string[] args) { var compilerinvocations1 = CompilerInvocationsReader.ReadInvocations(args[0]) .ToDictionary(x => x.ProjectFilePath); var compilerinvocations2 = CompilerInvocationsReader.ReadInvocations(args[1]) .ToDictionary(x => x.ProjectFilePath); var projectsInSecondButNotFirst = new List <string>(); foreach (var(projectPath, compilerInvocation2) in compilerinvocations2) { if (!compilerinvocations1.TryGetValue(projectPath, out var compilerInvocation1)) { projectsInSecondButNotFirst.Add(projectPath); continue; } var before = string.Join('\n', compilerInvocation1.CommandLineArguments.Split(' ').OrderByDescending(x => x)); var after = string.Join('\n', compilerInvocation2.CommandLineArguments.Split(' ').OrderByDescending(x => x));; var diff = InlineDiffBuilder.Diff(before, after); PrintDiff(diff); } if (projectsInSecondButNotFirst.Any()) { Console.WriteLine("Projects in second build but not in the first: "); Console.WriteLine(string.Join('\n', projectsInSecondButNotFirst)); } }
private void GenerateSources(Build build, string outputDirectory) { var compilerInvocations = CompilerInvocationsReader.ReadInvocations(build); foreach (var invocation in compilerInvocations) { GenerateSourcesForProject(invocation, outputDirectory); } }
/// <summary> /// Prints out reference info from binlog /// </summary> /// <param name="invocationContext"></param> /// <param name="binlog">Path to the binlog file.</param> /// <param name="top">Number of references to list (use '*' to show all).</param> static void Main( InvocationContext invocationContext, FileInfo binlog, string?top = null) { bool showMostReferencedAssemblies = false; int? numberOfItemsToShow = null; if (top is string && int.TryParse(top, out var number)) { numberOfItemsToShow = number; showMostReferencedAssemblies = true; } else if (top is string && top == "*") { numberOfItemsToShow = null; showMostReferencedAssemblies = true; } Console.WriteLine($"Reading in '{binlog.Name}'"); var timer = Stopwatch.StartNew(); var invocations = CompilerInvocationsReader.ReadInvocations(binlog.FullName).ToArray(); Console.WriteLine($"Read '{binlog.Name}' in {timer.Elapsed:hh\\:mm\\:ss\\.ff}"); var referenceHistogram = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase); foreach (var invocation in invocations) { var commandline = invocation.CommandLineArguments; var references = GetReferences(commandline); referenceHistogram.AddRange(references); } Console.WriteLine(); Console.WriteLine($"Number of unique references: {referenceHistogram.Keys.Count}"); Console.WriteLine(); if (showMostReferencedAssemblies) { RenderReferenceTable(referenceHistogram, numberOfItemsToShow, invocationContext.Console); Console.WriteLine(); } Console.WriteLine(); RenderFrequencyTable(referenceHistogram, invocationContext.Console); Console.WriteLine(); }
public void Parse1(string arg, string expected) { var result = CompilerInvocationsReader.TrimCompilerExeFromCommandLine(arg, CompilerInvocation.CSharp); Assert.Equal(expected, result); }