public void Export(AssemblyComparison assemblyComparison, OutputWriterFactory factory) { var xml = assemblyComparison.Diff.ToXml(); using var writer = factory.Create(Path.ChangeExtension(assemblyComparison.First.Name, "xml")); writer.Write(xml); }
public AssemblyComparison CompareAssemblyFiles(DiffConfig config, ComparisonFilter filter, params string[] assemblyFiles) { _config = config; _filter = filter; if (_progress != null) { _progress.SetMaxRange(assemblyFiles.Length); } if (assemblyFiles.Length == 0) { return(null); } AppDomainIsolationLevel level = _config.IsolationLevel; if (level == AppDomainIsolationLevel.AutoDetect) { level = IsolationDetector.AutoDetectIsolationLevelFiles(assemblyFiles); } AssemblyManager manager = AssemblyManagerFactory.Create(level); AssemblyComparison ac = new AssemblyComparison(); ac.Groups.Add(DoCompareFiles(manager, assemblyFiles)); manager.AllExtractionsComplete(); FilterResultSet(ac, filter); return(ac); }
public void LoadFrom(AssemblyComparison ac, bool preserveSelection) { string selection = null; if (preserveSelection && treeViewAdv1.SelectedNode != null) { selection = ((AssemblyGroupTreeItem)treeViewAdv1.SelectedNode.Tag).Group.Name; } treeViewAdv1.Model = new AssemblyComparisonModel(ac); int selIndex = 0; if (selection != null) { for (int i = 0; i < treeViewAdv1.Root.Children.Count; i++) { if (((AssemblyGroupTreeItem)treeViewAdv1.Root.Children[i].Tag).Name == selection) { selIndex = i; break; } } } if (selIndex < treeViewAdv1.Root.Children.Count) { treeViewAdv1.Root.Children[selIndex].IsSelected = true; } }
private static void DoCompareAndVerifyStillPresent(ComparisonFilter filter, params string[] names) { AssemblyComparison ac = DoCompare(ComparisonFilter.Default); Assert.AreEqual(Status.Present, FindInAssembly(ac, names).Status); ac.Recompare(filter); Assert.AreEqual(Status.Present, FindInAssembly(ac, names).Status); }
private static void DoCompareAndVerifyChange(ComparisonFilter filter, ChangeType withoutFilter, ChangeType withFilter, params string[] names) { AssemblyComparison ac = DoCompare(ComparisonFilter.Default); Assert.AreEqual(withoutFilter, FindInAssembly(ac, names).Change); ac.Recompare(filter); Assert.AreEqual(withFilter, FindInAssembly(ac, names).Change); }
public void DirCompare_OneEmpty() { AssemblyComparer ac = new AssemblyComparer(); AssemblyComparison results = ac.CompareAssemblyDirectories(false, DiffConfig.Default, ComparisonFilter.Default, Subjects.DirOne, Subjects.DirEmpty); // Two assemblies present in just one directories Assert.AreEqual(2, results.Groups.Count); Assert.AreEqual(1, results.Groups[0].Assemblies.Count); Assert.AreEqual(1, results.Groups[1].Assemblies.Count); }
public void Filters_TextFilter_NoMatches() { ComparisonFilter filter = new ComparisonFilter(); filter.TextFilter = "bogus"; AssemblyComparison ac = DoCompare(ComparisonFilter.Default); Assert.AreEqual(true, ac.Groups[0].Assemblies[1].FilterChildren <ICanAlign>().GetEnumerator().MoveNext()); ac.Recompare(filter); Assert.AreEqual(false, ac.Groups[0].Assemblies[1].FilterChildren <ICanAlign>().GetEnumerator().MoveNext()); }
private void FilterResultSet(AssemblyComparison ac, ComparisonFilter filter) { if (ac == null || filter == null) { return; } if (filter.ChangedItemsOnly) { var removeList = ac.Groups.ToList().Where(g => g.Change == ChangeType.None && !g.HasErrors); removeList.ToList().ForEach(i => ac.Groups.Remove(i)); } }
public void Export(AssemblyComparison assemblyComparison, OutputWriterFactory writerFactory) { // IDiffItem implementations are internal so parse from XML for now var xml = assemblyComparison.Diff.ToXml(); var doc = XDocument.Parse(xml); var name = assemblyComparison.First.Name; using var writer = writerFactory.Create(Path.ChangeExtension(name, "asciidoc")); writer.WriteLine($"== Breaking changes for {Path.GetFileNameWithoutExtension(name)}"); foreach (var typeElement in doc.Descendants("Type")) { writer.WriteLine(); WriteTypeElement(writer, typeElement); } }
private static ICanCompare FindInAssembly(AssemblyComparison ac, params string[] names) { ICanCompare current = ac.Groups[0].Assemblies[1]; for (int i = 0; i < names.Length; i++) { ICanCompare child = (ICanCompare)FindChildByName(current, names[i]); if ((i < names.Length - 1) && (child == null)) { Assert.Inconclusive("Did not find child named {0} in {1}.", names[i], current.Name); } current = child; } return(current); }
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { _progress.Close(); _progress = null; if (e.Error != null) { ThreadExceptionDialog ted = new ThreadExceptionDialog(e.Error); ted.ShowDialog(); } else { SetStatus(_eltl.HighestLoggedLevel); _ac = (AssemblyComparison)e.Result; if (_ac != null) { ApplyFilter(); } } }
public AssemblyComparison CompareAssemblyDirectories(bool recurse, DiffConfig config, ComparisonFilter filter, params string[] assemblyDirectories) { _config = config; _filter = filter; int totalFiles = 0; List <List <ICanAlign> > allEntries = new List <List <ICanAlign> >(); SearchOption option = recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; foreach (string dir in assemblyDirectories) { List <ICanAlign> entry = new List <ICanAlign>(); entry.AddRange(AssemblyDirectoryEntry.From(dir, Directory.GetFiles(dir, "*.dll", option))); entry.AddRange(AssemblyDirectoryEntry.From(dir, Directory.GetFiles(dir, "*.exe", option))); totalFiles += entry.Count; allEntries.Add(entry); } if (allEntries.Count == 0) { return(null); } AppDomainIsolationLevel level = _config.IsolationLevel; if (level == AppDomainIsolationLevel.AutoDetect) { level = IsolationDetector.AutoDetectIsolationLevelDirs(assemblyDirectories); } ListOperations.AlignListsNoParent(allEntries.ToArray()); AssemblyManager manager = AssemblyManagerFactory.Create(level); AssemblyComparison ac = new AssemblyComparison(); if (_progress != null) { _progress.SetMaxRange(totalFiles); } for (int j = 0; j < allEntries[0].Count; j++) { List <string> thisRun = new List <string>(); for (int i = 0; i < allEntries.Count; i++) { if (allEntries[i][j].Status == Status.Present) { thisRun.Add(((AssemblyDirectoryEntry)allEntries[i][j]).Path); } } ac.Groups.Add(DoCompareFiles(manager, thisRun.ToArray())); } manager.AllExtractionsComplete(); FilterResultSet(ac, filter); return(ac); }
public AssemblyComparisonModel(AssemblyComparison ac) { _ac = ac; }
public AssemblyComparisonTreeItem(AssemblyComparison ac) : base(Resources.VSObject_Assembly) { _ac = ac; }