diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets
index 55292f3..6be03ac 100644
--- a/.paket/Paket.Restore.targets
+++ b/.paket/Paket.Restore.targets
@@ -72,6 +72,9 @@
true
+
+ true
+
@@ -93,7 +96,7 @@
$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references
$(MSBuildProjectDirectory)\paket.references
-
+
false
true
true
@@ -132,11 +135,11 @@
-
+
-
+
$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])
$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])
diff --git a/License.txt b/License.txt
new file mode 100644
index 0000000..25459fb
--- /dev/null
+++ b/License.txt
@@ -0,0 +1,175 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use thes
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
\ No newline at end of file
diff --git a/README.md b/README.md
index 1fbc7f9..ad61ae9 100644
--- a/README.md
+++ b/README.md
@@ -22,5 +22,12 @@ Works with `.NET Core` and `.NET 4.6` and up.
Supports `dotnet xunit`, `dotnet test`, `xunit.console.runner` and tests will be runnable in your IDE through VSTest and jetBrains Rider.
+### [Differ](src/Differ/README.md)
+
+Compare and Diff assemblies from different sources e.g. assemblies, directories, GitHub commit, NuGet packages.
+Useful for determining what changes are introduced across versions, and if any are _breaking_.
+
+Outputs differences in XML, Markdown or AsciiDoc.
+
diff --git a/src/Differ/AssemblyDiffPair.cs b/src/Differ/AssemblyDiffPair.cs
new file mode 100644
index 0000000..eaba286
--- /dev/null
+++ b/src/Differ/AssemblyDiffPair.cs
@@ -0,0 +1,19 @@
+using System;
+using System.IO;
+using JustAssembly.Core;
+
+namespace Differ
+{
+ public class AssemblyDiffPair
+ {
+ public AssemblyDiffPair(FileInfo first, FileInfo second)
+ {
+ First = first ?? throw new ArgumentNullException(nameof(first));
+ Second = second ?? throw new ArgumentNullException(nameof(second));
+ }
+
+ public FileInfo First { get; }
+ public FileInfo Second { get; }
+ public IDiffItem Diff { get; set; }
+ }
+}
diff --git a/src/Differ/Differ.csproj b/src/Differ/Differ.csproj
new file mode 100644
index 0000000..641110f
--- /dev/null
+++ b/src/Differ/Differ.csproj
@@ -0,0 +1,42 @@
+
+
+ Exe
+ net462
+ 7.1
+
+
+
+
+
+
+
+
+
+
+
+
+ lib\JustAssembly.API.dll
+
+
+ lib\JustAssembly.Core.dll
+
+
+ lib\JustAssembly.Infrastructure.dll
+
+
+ lib\JustDecompile.External.JustAssembly.dll
+
+
+ lib\JustDecompiler.dll
+
+
+ lib\Telerik.JustDecompile.Mono.Cecil.dll
+
+
+ lib\Telerik.JustDecompile.Mono.Cecil.Mdb.dll
+
+
+ lib\Telerik.JustDecompile.Mono.Cecil.Pdb.dll
+
+
+
\ No newline at end of file
diff --git a/src/Differ/Exporters/AsciiDocExporter.cs b/src/Differ/Exporters/AsciiDocExporter.cs
new file mode 100644
index 0000000..6e84dd7
--- /dev/null
+++ b/src/Differ/Exporters/AsciiDocExporter.cs
@@ -0,0 +1,87 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Xml.Linq;
+using JustAssembly.Core;
+
+namespace Differ.Exporters
+{
+ public class AsciiDocExporter : IExporter
+ {
+ public string Format { get; } = "asciidoc";
+
+ public void Export(AssemblyDiffPair assemblyDiffPair, string outputPath)
+ {
+ // IDiffItem implementations are internal so parse from XML for now
+ var xml = assemblyDiffPair.Diff.ToXml();
+ var doc = XDocument.Parse(xml);
+ var name = assemblyDiffPair.First.Name;
+ using (var writer = new StreamWriter(Path.Combine(outputPath, Path.ChangeExtension(name, "asciidoc"))))
+ {
+ writer.WriteLine($"== Breaking changes for {Path.GetFileNameWithoutExtension(name)}");
+ writer.WriteLine();
+
+ foreach (var typeElement in doc.Descendants("Type"))
+ WriteTypeElement(writer, typeElement);
+ }
+ }
+
+ private void WriteTypeElement(StreamWriter writer, XElement typeElement)
+ {
+ var typeName = typeElement.Attribute("Name")?.Value;
+ var diffType = (DiffType) Enum.Parse(typeof(DiffType), typeElement.Attribute("DiffType").Value);
+
+ switch(diffType)
+ {
+ case DiffType.Deleted:
+ writer.WriteLine($"[float]{Environment.NewLine}=== `{typeName}` is deleted");
+ break;
+ case DiffType.Modified:
+ WriteMemberElements(writer, typeName, typeElement);
+ break;
+ case DiffType.New:
+ writer.WriteLine($"[float]{Environment.NewLine}=== `{typeName}` is added");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ private void WriteMemberElements(StreamWriter writer, string typeName, XElement typeElement)
+ {
+ var memberElements = typeElement.Elements("Method").Concat(typeElement.Elements("Property"));
+
+ if (memberElements.Any())
+ writer.WriteLine($"[float]{Environment.NewLine}=== `{typeName}`");
+
+ foreach (var memberElement in memberElements)
+ {
+ var memberName = memberElement.Attribute("Name")?.Value;
+ if (!string.IsNullOrEmpty(memberName) && Enum.TryParse(typeElement.Attribute("DiffType")?.Value, out DiffType diffType))
+ {
+ switch (diffType)
+ {
+ case DiffType.Deleted:
+ writer.WriteLine($"[float]{Environment.NewLine}==== `{memberName}` is deleted");
+ break;
+ case DiffType.Modified:
+ var diffItem = memberElement.Descendants("DiffItem").FirstOrDefault();
+ if (diffItem != null)
+ {
+ writer.WriteLine($"[float]{Environment.NewLine}==== `{memberName}`");
+ writer.WriteLine(
+ Regex.Replace(diffItem.Value, "changed from (.*?) to (.*).", "changed from `$1` to `$2`."));
+ }
+ break;
+ case DiffType.New:
+ writer.WriteLine($"[float]{Environment.NewLine}==== `{memberName}` is added");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Differ/Exporters/ExporterCollection.cs b/src/Differ/Exporters/ExporterCollection.cs
new file mode 100644
index 0000000..117ac45
--- /dev/null
+++ b/src/Differ/Exporters/ExporterCollection.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+
+namespace Differ.Exporters
+{
+ public class ExporterCollection : KeyedCollection
+ {
+ protected override string GetKeyForItem(IExporter item) => item.Format;
+
+ public ExporterCollection(params IExporter[] exporters)
+ {
+ if (exporters == null)
+ throw new ArgumentNullException(nameof(exporters));
+
+ foreach (var exporter in exporters)
+ this.Add(exporter);
+ }
+
+ public string SupportedFormats => string.Join(", ", this.Select(e => e.Format));
+ }
+}
diff --git a/src/Differ/Exporters/IExporter.cs b/src/Differ/Exporters/IExporter.cs
new file mode 100644
index 0000000..b045804
--- /dev/null
+++ b/src/Differ/Exporters/IExporter.cs
@@ -0,0 +1,11 @@
+using JustAssembly.Core;
+
+namespace Differ.Exporters
+{
+ public interface IExporter
+ {
+ string Format { get; }
+
+ void Export(AssemblyDiffPair assemblyDiffPair, string outputPath);
+ }
+}
diff --git a/src/Differ/Exporters/MarkdownExporter.cs b/src/Differ/Exporters/MarkdownExporter.cs
new file mode 100644
index 0000000..0f0a0e5
--- /dev/null
+++ b/src/Differ/Exporters/MarkdownExporter.cs
@@ -0,0 +1,87 @@
+using System;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Xml.Linq;
+using JustAssembly.Core;
+
+namespace Differ.Exporters
+{
+ public class MarkdownExporter : IExporter
+ {
+ public string Format { get; } = "markdown";
+
+ public void Export(AssemblyDiffPair assemblyDiffPair, string outputPath)
+ {
+ // IDiffItem implementations are internal so parse from XML for now
+ var xml = assemblyDiffPair.Diff.ToXml();
+ var doc = XDocument.Parse(xml);
+ var name = assemblyDiffPair.First.Name;
+ using (var writer = new StreamWriter(Path.Combine(outputPath, Path.ChangeExtension(name, "md"))))
+ {
+ writer.WriteLine($"# Breaking changes for {Path.GetFileNameWithoutExtension(name)}");
+ writer.WriteLine();
+
+ foreach (var typeElement in doc.Descendants("Type"))
+ WriteTypeElement(writer, typeElement);
+ }
+ }
+
+ private void WriteTypeElement(StreamWriter writer, XElement typeElement)
+ {
+ var typeName = typeElement.Attribute("Name")?.Value;
+ var diffType = (DiffType) Enum.Parse(typeof(DiffType), typeElement.Attribute("DiffType").Value);
+
+ switch(diffType)
+ {
+ case DiffType.Deleted:
+ writer.WriteLine($"## `{typeName}` is deleted");
+ break;
+ case DiffType.Modified:
+ WriteMemberElements(writer, typeName, typeElement);
+ break;
+ case DiffType.New:
+ writer.WriteLine($"## `{typeName}` is added");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ private void WriteMemberElements(StreamWriter writer, string typeName, XElement typeElement)
+ {
+ var memberElements = typeElement.Elements("Method").Concat(typeElement.Elements("Property"));
+
+ if (memberElements.Any())
+ writer.WriteLine($"## `{typeName}`");
+
+ foreach (var memberElement in memberElements)
+ {
+ var memberName = memberElement.Attribute("Name")?.Value;
+ if (!string.IsNullOrEmpty(memberName) && Enum.TryParse(typeElement.Attribute("DiffType")?.Value, out DiffType diffType))
+ {
+ switch (diffType)
+ {
+ case DiffType.Deleted:
+ writer.WriteLine($"### `{memberName}` is deleted");
+ break;
+ case DiffType.Modified:
+ var diffItem = memberElement.Descendants("DiffItem").FirstOrDefault();
+ if (diffItem != null)
+ {
+ writer.WriteLine($"### `{memberName}`");
+ writer.WriteLine(
+ Regex.Replace(diffItem.Value, "changed from (.*?) to (.*).", "changed from `$1` to `$2`."));
+ }
+ break;
+ case DiffType.New:
+ writer.WriteLine($"### `{memberName}` is added");
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Differ/Exporters/XmlExporter.cs b/src/Differ/Exporters/XmlExporter.cs
new file mode 100644
index 0000000..26ed075
--- /dev/null
+++ b/src/Differ/Exporters/XmlExporter.cs
@@ -0,0 +1,17 @@
+using System;
+using System.IO;
+
+namespace Differ.Exporters
+{
+ public class XmlExporter : IExporter
+ {
+ public string Format { get; } = "xml";
+
+ public void Export(AssemblyDiffPair assemblyDiffPair, string outputPath)
+ {
+ var xml = assemblyDiffPair.Diff.ToXml();
+ using (var writer = new StreamWriter(Path.Combine(outputPath, Path.ChangeExtension(assemblyDiffPair.First.Name, "xml"))))
+ writer.Write(xml);
+ }
+ }
+}
diff --git a/src/Differ/Program.cs b/src/Differ/Program.cs
new file mode 100644
index 0000000..b0aee03
--- /dev/null
+++ b/src/Differ/Program.cs
@@ -0,0 +1,142 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Differ.Exporters;
+using Differ.Providers;
+using Differ.Providers.GitHub;
+using Differ.Providers.NuGet;
+using JustAssembly.Core;
+using Mono.Options;
+
+namespace Differ
+{
+ internal static class Program
+ {
+ private static string _format = "xml";
+ private static bool _help;
+ private static string _output = Directory.GetCurrentDirectory();
+ private static HashSet _targets;
+
+ private static HashSet Targets =>
+ _targets ?? (_targets = new HashSet(StringComparer.OrdinalIgnoreCase));
+
+ static void Main(string[] args)
+ {
+ var providers = new AssemblyProviderFactoryCollection(
+ new AssemblyProviderFactory(),
+ new DirectoryAssemblyProviderFactory(),
+ new NuGetAssemblyProviderFactory(new Providers.NuGet.NuGet(
+ Environment.GetEnvironmentVariable("NUGET"),
+ Environment.GetEnvironmentVariable("NUGET_SOURCES"))),
+ new GitHubAssemblyProviderFactory(new Git(Environment.GetEnvironmentVariable("GIT")))
+ );
+
+ var exporters = new ExporterCollection(
+ new XmlExporter(),
+ new MarkdownExporter(),
+ new AsciiDocExporter()
+ );
+
+ var options = new OptionSet
+ {
+ {"t|target=", "the assembly targets. Defaults to *all* assemblies located by the provider", AddTarget },
+ {"f|format=", $"the format of the diff output. Supported formats are {exporters.SupportedFormats}. Defaults to {_format}", f => _format = f},
+ {"o|output=", "the output directory. Defaults to current directory", o => _output = o},
+ {"h|?|help", "show this message and exit", h => _help = h != null},
+ };
+
+ if (args.Length < 2)
+ {
+ ShowHelp(options, providers);
+ Environment.ExitCode = 1;
+ return;
+ }
+
+ List unflaggedArgs;
+ try
+ {
+ unflaggedArgs = options.Parse(args);
+ }
+ catch (OptionException e)
+ {
+ Console.WriteLine(e.Message);
+ Console.WriteLine("Try 'Differ.exe --help' for more information.");
+ Environment.ExitCode = 1;
+ return;
+ }
+
+ if (_help)
+ {
+ ShowHelp(options, providers);
+ return;
+ }
+
+ try
+ {
+ var firstProvider = providers.GetProvider(unflaggedArgs[0]);
+ var secondProvider = providers.GetProvider(unflaggedArgs[1]);
+
+ if (!exporters.Contains(_format))
+ throw new Exception($"No exporter for format '{_format}'");
+
+ var exporter = exporters[_format];
+
+ foreach (var assemblyPair in CreateAssemblyPairs(firstProvider, secondProvider))
+ {
+ assemblyPair.Diff =
+ APIDiffHelper.GetAPIDifferences(assemblyPair.First.FullName, assemblyPair.Second.FullName);
+
+ if (assemblyPair.Diff == null)
+ {
+ Console.WriteLine($"No diff between {assemblyPair.First.FullName} and {assemblyPair.Second.FullName}");
+ continue;
+ }
+
+ exporter.Export(assemblyPair, _output);
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e);
+ Environment.ExitCode = 1;
+ }
+ }
+
+ private static IEnumerable CreateAssemblyPairs(IAssemblyProvider firstProvider, IAssemblyProvider secondProvider) =>
+ firstProvider.GetAssemblies(_targets).Join(secondProvider.GetAssemblies(_targets),
+ f => f.Name.ToUpperInvariant(),
+ f => f.Name.ToUpperInvariant(),
+ (f1, f2) => new AssemblyDiffPair(f1, f2));
+
+ private static void AddTarget(string input)
+ {
+ if (string.IsNullOrEmpty(input))
+ return;
+
+ var parts = input.Split(',', '|');
+ foreach (var part in parts)
+ Targets.Add(part);
+ }
+
+ private static void ShowHelp(OptionSet options, AssemblyProviderFactoryCollection providerFactoryCollection)
+ {
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.WriteLine("Differ");
+ Console.WriteLine("------");
+ Console.WriteLine("Diffs assemblies from different sources");
+ Console.WriteLine();
+ Console.WriteLine("Differ.exe [Options]");
+ Console.WriteLine();
+ Console.WriteLine("Supported Assembly Providers:");
+ Console.WriteLine();
+ foreach (var providerFactory in providerFactoryCollection)
+ Console.WriteLine($" {providerFactory.Format}");
+ Console.WriteLine();
+ Console.WriteLine("Options:");
+ options.WriteOptionDescriptions(Console.Out);
+ Console.WriteLine();
+ Console.ResetColor();
+ }
+ }
+}
diff --git a/src/Differ/Providers/AssemblyProvider.cs b/src/Differ/Providers/AssemblyProvider.cs
new file mode 100644
index 0000000..5e8d84c
--- /dev/null
+++ b/src/Differ/Providers/AssemblyProvider.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Telerik.JustDecompiler.Ast.Expressions;
+
+namespace Differ.Providers
+{
+ public class AssemblyProvider : IAssemblyProvider
+ {
+ private readonly string _assemblyPath;
+
+ public AssemblyProvider(string assemblyPath)
+ {
+ if (assemblyPath == null)
+ throw new ArgumentNullException(nameof(assemblyPath));
+
+ if (!File.Exists(assemblyPath))
+ throw new FileNotFoundException($"no file found at {assemblyPath}");
+
+ if (Path.GetExtension(assemblyPath) != ".dll")
+ throw new Exception("file is not a dll");
+
+ _assemblyPath = assemblyPath;
+ }
+
+ public IEnumerable GetAssemblies(IEnumerable targets)
+ {
+ yield return new FileInfo(_assemblyPath);
+ }
+ }
+
+ public class AssemblyProviderFactory : IAssemblyProviderFactory
+ {
+ public string Name { get; } = "assembly";
+
+ public string Format => $"{Name}|";
+
+ public IAssemblyProvider Create(string[] command)
+ {
+ if (command.Length != 1)
+ throw new Exception("command must have a length of 1");
+
+ return new AssemblyProvider(command[0]);
+ }
+ }
+}
diff --git a/src/Differ/Providers/AssemblyProviderFactoryCollection.cs b/src/Differ/Providers/AssemblyProviderFactoryCollection.cs
new file mode 100644
index 0000000..c1e6ac8
--- /dev/null
+++ b/src/Differ/Providers/AssemblyProviderFactoryCollection.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+
+namespace Differ.Providers
+{
+ public class AssemblyProviderFactoryCollection : IEnumerable
+ {
+ private readonly AssemblyFileInfoProviderCollection _providers;
+
+ public AssemblyProviderFactoryCollection(params IAssemblyProviderFactory[] providerFactories) =>
+ _providers = new AssemblyFileInfoProviderCollection(providerFactories);
+
+ public IAssemblyProvider GetProvider(string command)
+ {
+ if (command == null)
+ throw new ArgumentNullException(nameof(command));
+
+ var commandParts = command.Split('|');
+ var providerName = commandParts[0];
+
+ if (!_providers.Contains(providerName))
+ throw new Exception($"No provider factory for {providerName}");
+
+ var provider = _providers[providerName].Create(commandParts.Skip(1).ToArray());
+ return provider;
+ }
+
+ private class AssemblyFileInfoProviderCollection : KeyedCollection
+ {
+ public AssemblyFileInfoProviderCollection(IEnumerable providerFactories)
+ {
+ if (providerFactories == null)
+ throw new ArgumentNullException(nameof(providerFactories));
+
+ foreach (var factory in providerFactories)
+ this.Add(factory);
+ }
+
+ protected override string GetKeyForItem(IAssemblyProviderFactory item) => item.Name;
+ }
+
+ public IEnumerator GetEnumerator() => _providers.GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+ }
+}
diff --git a/src/Differ/Providers/DirectoryAssemblyProvider.cs b/src/Differ/Providers/DirectoryAssemblyProvider.cs
new file mode 100644
index 0000000..a16e48a
--- /dev/null
+++ b/src/Differ/Providers/DirectoryAssemblyProvider.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+namespace Differ.Providers
+{
+ public class DirectoryAssemblyProvider : IAssemblyProvider
+ {
+ private readonly string _assemblyDirectory;
+
+ public DirectoryAssemblyProvider(string assemblyDirectory)
+ {
+ if (assemblyDirectory == null)
+ throw new ArgumentNullException(nameof(assemblyDirectory));
+
+ if (!Directory.Exists(assemblyDirectory))
+ throw new DirectoryNotFoundException($"No directory found at {assemblyDirectory}");
+
+ _assemblyDirectory = assemblyDirectory;
+ }
+
+ public IEnumerable GetAssemblies(IEnumerable targets) =>
+ Directory.EnumerateFiles(_assemblyDirectory, "*.dll")
+ .Where(f => targets?.Contains(Path.GetFileNameWithoutExtension(f)) ?? true)
+ .Select(f => new FileInfo(f));
+ }
+
+ public class DirectoryAssemblyProviderFactory : IAssemblyProviderFactory
+ {
+ public string Name { get; } = "directory";
+
+ public string Format => $"{Name}|";
+
+ public IAssemblyProvider Create(string[] command)
+ {
+ if (command.Length != 1)
+ throw new Exception("command must have a length of 1");
+
+ return new DirectoryAssemblyProvider(command[0]);
+ }
+ }
+}
diff --git a/src/Differ/Providers/ExecutableBase.cs b/src/Differ/Providers/ExecutableBase.cs
new file mode 100644
index 0000000..53a9558
--- /dev/null
+++ b/src/Differ/Providers/ExecutableBase.cs
@@ -0,0 +1,25 @@
+using System;
+using System.IO;
+
+namespace Differ.Providers
+{
+ public class ExecutableBase
+ {
+ protected string FindExecutable(string name)
+ {
+ var path = Environment.GetEnvironmentVariable("PATH");
+
+ if (string.IsNullOrEmpty(path))
+ throw new Exception("PATH environment variable is null or empty");
+
+ foreach (var p in path.Split(';'))
+ {
+ var exe = Path.Combine(Environment.ExpandEnvironmentVariables(p), name);
+ if (File.Exists(exe))
+ return exe;
+ }
+
+ throw new Exception($"Cannot find {name} in PATH environment variable. Add {name} to PATH or use specific environment variable");
+ }
+ }
+}
diff --git a/src/Differ/Providers/GitHub/Git.cs b/src/Differ/Providers/GitHub/Git.cs
new file mode 100644
index 0000000..7816ed5
--- /dev/null
+++ b/src/Differ/Providers/GitHub/Git.cs
@@ -0,0 +1,48 @@
+using System;
+using System.IO;
+using System.Linq;
+using ProcNet;
+
+namespace Differ.Providers.GitHub
+{
+ public interface IGit
+ {
+ ProcessResult Execute(string workingDirectory, params string[] args);
+ }
+
+ public class Git : ExecutableBase, IGit
+ {
+ private readonly string _executable;
+ private const string GitExe = "git.exe";
+
+ public Git(string executable = null)
+ {
+ if (!string.IsNullOrEmpty(executable))
+ {
+ if (!File.Exists(executable))
+ throw new FileNotFoundException($"{GitExe} does not exist at {executable}");
+
+ _executable = executable;
+ }
+ else
+ _executable = FindExecutable(GitExe);
+ }
+
+
+ public ProcessResult Execute(string workingDirectory, params string[] args)
+ {
+ var startArguments = new StartArguments(_executable, args)
+ {
+ WorkingDirectory = workingDirectory,
+ WaitForStreamReadersTimeout = TimeSpan.FromSeconds(30)
+ };
+
+ var processResult = Proc.Start(startArguments);
+ if (processResult.ExitCode == 0)
+ return processResult;
+
+ var lines = string.Join(Environment.NewLine, processResult.ConsoleOut.Select(c => c.Line));
+ throw new Exception($"{GitExe} returned non-zero exit code: {lines}");
+ }
+ }
+}
diff --git a/src/Differ/Providers/GitHub/GitHubAssemblyProvider.cs b/src/Differ/Providers/GitHub/GitHubAssemblyProvider.cs
new file mode 100644
index 0000000..4a3ff7b
--- /dev/null
+++ b/src/Differ/Providers/GitHub/GitHubAssemblyProvider.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using ProcNet;
+
+namespace Differ.Providers.GitHub
+{
+ public class GitHubAssemblyProviderFactory : IAssemblyProviderFactory
+ {
+ private readonly IGit _git;
+
+ public GitHubAssemblyProviderFactory(IGit git) =>
+ _git = git;
+
+ public string Name { get; } = "github";
+
+ public string Format => $"{Name}|/|||";
+
+ public IAssemblyProvider Create(string[] command) =>
+ new GitHubAssemblyProvider(_git, command);
+ }
+
+ public class GitHubAssemblyProvider : IAssemblyProvider
+ {
+ private readonly IGit _git;
+ private readonly GitHubDiffCommand _command;
+
+ public GitHubAssemblyProvider(IGit git, string[] command)
+ {
+ _git = git;
+ _command = new GitHubDiffCommand(command);
+ }
+
+ public IEnumerable GetAssemblies(IEnumerable targets)
+ {
+ var tempDir = Path.Combine(_command.TempDir, "differ", "github");
+ if (!Directory.Exists(tempDir))
+ Directory.CreateDirectory(tempDir);
+
+ var repoDirectory = Path.GetFullPath(Path.Combine(tempDir, _command.Repo));
+ var repoUri = $"git@github.com:{_command.Owner}/{_command.Repo}.git";
+
+ ProcessResult result;
+
+ if (!Directory.Exists(repoDirectory))
+ // TODO: do something with stdout
+ result = _git.Execute(tempDir, "clone", repoUri, _command.Repo);
+
+ // TODO: do something with stdout
+ result = _git.Execute(repoDirectory, "reset", "--hard");
+ result = _git.Execute(repoDirectory, "checkout", _command.Commit);
+
+ // compile
+ var arguments = new StartArguments(_command.BuildCommand, _command.BuildArguments)
+ {
+ WorkingDirectory = repoDirectory,
+ WaitForStreamReadersTimeout = TimeSpan.FromMinutes(1),
+ };
+
+ result = Proc.Start(arguments, TimeSpan.FromMinutes(10));
+
+ var output = Path.GetFullPath(Path.Combine(repoDirectory, _command.Output));
+ var isFile = false;
+ var isDirectory = false;
+
+ if (File.Exists(output))
+ isFile = true;
+ else if (Directory.Exists(output))
+ isDirectory = true;
+
+ if (!isFile && !isDirectory)
+ throw new Exception($"file or directory not found at {output}");
+
+ var commitDirectory = Path.Combine(tempDir, _command.Repo + "-" + _command.Commit);
+ if (!Directory.Exists(commitDirectory))
+ Directory.CreateDirectory(commitDirectory);
+
+ if (isFile)
+ File.Copy(output, Path.Combine(commitDirectory, Path.GetFileName(output)), true);
+ else
+ {
+ foreach (var file in Directory.EnumerateFiles(output, "*.dll"))
+ {
+ var fileInfo = new FileInfo(file);
+ File.Copy(fileInfo.FullName, Path.Combine(commitDirectory, fileInfo.Name), true);
+ }
+ }
+
+ return Directory.EnumerateFiles(commitDirectory, "*.dll")
+ .Where(f => targets?.Contains(Path.GetFileNameWithoutExtension(f)) ?? true)
+ .Select(f => new FileInfo(f));
+ }
+ }
+}
diff --git a/src/Differ/Providers/GitHub/GitHubDiffCommand.cs b/src/Differ/Providers/GitHub/GitHubDiffCommand.cs
new file mode 100644
index 0000000..adaf9d5
--- /dev/null
+++ b/src/Differ/Providers/GitHub/GitHubDiffCommand.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Linq;
+
+namespace Differ.Providers.GitHub
+{
+ public class GitHubDiffCommand
+ {
+ public GitHubDiffCommand(string[] command)
+ {
+ if (command == null)
+ throw new ArgumentNullException(nameof(command));
+
+ if (command.Length < 4)
+ throw new Exception("command must have a minimum length of 4");
+
+ var ownerAndRepo = command[0].Split('/');
+
+ if (ownerAndRepo.Length != 2)
+ throw new Exception("first command value must be owner and repo in the form /");
+
+ Owner = ownerAndRepo[0];
+ Repo = ownerAndRepo[1];
+ Commit = command[1];
+
+ var commandAndArgs = command[2].Split(' ');
+
+ BuildCommand = commandAndArgs[0];
+
+ if (commandAndArgs.Length > 1)
+ BuildArguments = commandAndArgs.Skip(1).ToArray();
+
+ Output = command[3];
+ }
+
+ public string Owner { get; }
+
+ public string Repo { get; }
+
+ public string Commit { get; }
+
+ public string BuildCommand { get; }
+
+ public string[] BuildArguments { get; }
+
+ public string Output { get; }
+
+ public string TempDir { get; } = Environment.GetEnvironmentVariable("TEMP");
+ }
+}
diff --git a/src/Differ/Providers/IAssemblyProvider.cs b/src/Differ/Providers/IAssemblyProvider.cs
new file mode 100644
index 0000000..ed24b98
--- /dev/null
+++ b/src/Differ/Providers/IAssemblyProvider.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+using System.IO;
+
+namespace Differ.Providers
+{
+ public interface IAssemblyProvider
+ {
+ IEnumerable GetAssemblies(IEnumerable targets);
+ }
+}
diff --git a/src/Differ/Providers/IAssemblyProviderFactory.cs b/src/Differ/Providers/IAssemblyProviderFactory.cs
new file mode 100644
index 0000000..f34cdfa
--- /dev/null
+++ b/src/Differ/Providers/IAssemblyProviderFactory.cs
@@ -0,0 +1,10 @@
+namespace Differ.Providers
+{
+ public interface IAssemblyProviderFactory
+ {
+ string Name { get; }
+ string Format { get; }
+
+ IAssemblyProvider Create(string[] command);
+ }
+}
diff --git a/src/Differ/Providers/NuGet/NuGet.cs b/src/Differ/Providers/NuGet/NuGet.cs
new file mode 100644
index 0000000..f84028f
--- /dev/null
+++ b/src/Differ/Providers/NuGet/NuGet.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using ProcNet;
+
+namespace Differ.Providers.NuGet
+{
+ public interface INuGet
+ {
+ NuGetPackage InstallPackage(string packageName, string version, string targetDirectory);
+ }
+
+ public class NuGet : ExecutableBase, INuGet
+ {
+ private const string NugetExe = "nuget.exe";
+ private readonly string[] _sources = { "https://www.nuget.org/api/v2/", "https://api.nuget.org/v3/index.json" };
+ private readonly string _executable;
+
+ public NuGet(string executable = null, string sources = null)
+ {
+ if (!string.IsNullOrEmpty(sources))
+ _sources = sources.Split(';');
+
+ if (!string.IsNullOrEmpty(executable))
+ {
+ if (!File.Exists(executable))
+ throw new FileNotFoundException($"{NugetExe} does not exist at {executable}");
+
+ _executable = executable;
+ }
+ else
+ _executable = FindExecutable(NugetExe);
+ }
+
+ public NuGetPackage InstallPackage(string packageName, string version, string targetDirectory)
+ {
+ if (!Directory.Exists(targetDirectory))
+ Directory.CreateDirectory(targetDirectory);
+
+ var args = new List
+ {
+ "install", packageName,
+ "-Version", version,
+ "-ExcludeVersion", "-NonInteractive"
+ };
+
+ foreach (var source in _sources)
+ {
+ args.Add("-Source");
+ args.Add(source);
+ }
+
+ var startArguments = new StartArguments(_executable, args)
+ {
+ WorkingDirectory = targetDirectory
+ };
+
+ var processResult = Proc.Start(startArguments);
+ if (processResult.ExitCode != 0)
+ {
+ var lines = string.Join(Environment.NewLine, processResult.ConsoleOut.Select(c => c.Line));
+ throw new Exception($"{NugetExe} returned non-zero exit code: {lines}");
+ }
+
+ return new NuGetPackage(Path.Combine(targetDirectory, packageName));
+ }
+ }
+}
diff --git a/src/Differ/Providers/NuGet/NuGetAssemblyProvider.cs b/src/Differ/Providers/NuGet/NuGetAssemblyProvider.cs
new file mode 100644
index 0000000..7668b99
--- /dev/null
+++ b/src/Differ/Providers/NuGet/NuGetAssemblyProvider.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+namespace Differ.Providers.NuGet
+{
+ public class NuGetAssemblyProviderFactory : IAssemblyProviderFactory
+ {
+ private readonly INuGet _installer;
+
+ public NuGetAssemblyProviderFactory(INuGet installer) =>
+ _installer = installer ?? throw new ArgumentNullException(nameof(installer));
+
+ public string Name { get; } = "nuget";
+
+ public string Format => $"{Name}|||[framework version]";
+
+ public IAssemblyProvider Create(string[] command) =>
+ new NuGetAssemblyProvider(_installer, command);
+ }
+
+ public class NuGetAssemblyProvider : IAssemblyProvider
+ {
+ private readonly INuGet _installer;
+ private readonly NuGetDiffCommand _command;
+
+ public NuGetAssemblyProvider(INuGet installer, string[] command)
+ {
+ _installer = installer ?? throw new ArgumentNullException(nameof(installer));
+ _command = new NuGetDiffCommand(command);
+ }
+
+ public IEnumerable GetAssemblies(IEnumerable targets)
+ {
+ var tempDir = Path.Combine(_command.TempDir, "differ", "nuget");
+ if (!Directory.Exists(tempDir))
+ Directory.CreateDirectory(tempDir);
+
+ var packageDirectory = Path.Combine(tempDir, _command.Package);
+
+ if (!Directory.Exists(packageDirectory))
+ Directory.CreateDirectory(packageDirectory);
+
+ var versionDirectory = Path.Combine(packageDirectory, _command.Version);
+ var package = _installer.InstallPackage(_command.Package, _command.Version, versionDirectory);
+ var packageFrameworks =
+ new HashSet(package.FrameworkVersions.Select(f => f.GetShortFolderName()), StringComparer.InvariantCultureIgnoreCase);
+
+ var frameworkVersion = packageFrameworks.First();
+
+ if (_command.FrameworkVersion != null)
+ {
+ if (packageFrameworks.Contains(_command.FrameworkVersion))
+ frameworkVersion = _command.FrameworkVersion;
+ else
+ Console.WriteLine($"{package.Id} does not contain framework " +
+ $"{_command.FrameworkVersion}. Using {frameworkVersion}");
+ }
+
+ // dependent assemblies need to copied to the same directory as the target assembly
+ CopyAssemblies(package, frameworkVersion);
+
+ return Directory.EnumerateFiles(Path.Combine(package.Path, "lib", frameworkVersion), "*.dll")
+ .Where(f => targets?.Contains(Path.GetFileNameWithoutExtension(f)) ?? true)
+ .Select(f => new FileInfo(f));
+ }
+
+ private void CopyAssemblies(NuGetPackage package, string frameworkVersion)
+ {
+ foreach (var dependency in package.Dependencies)
+ {
+ var nearest = dependency.GetNearest(frameworkVersion);
+ var dependencyPath = Path.Combine(dependency.Path, "lib", nearest.GetShortFolderName());
+
+ foreach (var file in Directory.EnumerateFiles(dependencyPath))
+ {
+ var fileInfo = new FileInfo(file);
+ File.Copy(fileInfo.FullName, Path.Combine(package.Path, "lib", frameworkVersion, fileInfo.Name), true);
+ }
+ }
+ }
+ }
+}
diff --git a/src/Differ/Providers/NuGet/NuGetDiffCommand.cs b/src/Differ/Providers/NuGet/NuGetDiffCommand.cs
new file mode 100644
index 0000000..164cdf0
--- /dev/null
+++ b/src/Differ/Providers/NuGet/NuGetDiffCommand.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Text;
+
+namespace Differ.Providers.NuGet
+{
+ public class NuGetDiffCommand
+ {
+ public NuGetDiffCommand(string[] command)
+ {
+ if (command == null)
+ throw new ArgumentNullException(nameof(command));
+
+ if (command.Length < 2)
+ throw new Exception("command must have a minimum length of 2");
+
+ Package = command[0];
+ Version = command[1];
+
+ if (command.Length > 2)
+ FrameworkVersion = command[2];
+ }
+
+ public string Package { get; }
+
+ public string Version { get; }
+
+ public string FrameworkVersion { get; }
+
+ public string TempDir { get; } = Environment.GetEnvironmentVariable("TEMP");
+ }
+}
diff --git a/src/Differ/Providers/NuGet/NuGetPackage.cs b/src/Differ/Providers/NuGet/NuGetPackage.cs
new file mode 100644
index 0000000..d6b5244
--- /dev/null
+++ b/src/Differ/Providers/NuGet/NuGetPackage.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Xml.Linq;
+using NuGet.Frameworks;
+
+namespace Differ.Providers.NuGet
+{
+ public class NuGetPackage : NuGetPackageBase
+ {
+ public NuGetPackage(string path) : base(path)
+ {
+ var directory = new DirectoryInfo(path);
+ var parentDirectory = directory.Parent;
+ if (parentDirectory != null)
+ {
+ Dependencies = Directory.GetDirectories(parentDirectory.FullName)
+ .Where(d => System.IO.Path.GetFileName(d) != directory.Name)
+ .Select(d => new NuGetPackageDependency(d))
+ .ToList();
+ }
+ }
+
+ public IReadOnlyList Dependencies { get; }
+ }
+
+ public class NuGetPackageDependency : NuGetPackageBase
+ {
+ public NuGetPackageDependency(string directory) : base(directory)
+ {
+ }
+ }
+
+ public abstract class NuGetPackageBase : INuGetPackage
+ {
+ private static readonly FrameworkReducer Reducer = new FrameworkReducer();
+
+ protected NuGetPackageBase(string directory)
+ {
+ if (directory == null)
+ throw new ArgumentNullException(nameof(directory));
+
+ if (!Directory.Exists(directory))
+ throw new DirectoryNotFoundException($"{directory} does not exist");
+
+ var packageZip = Directory.EnumerateFiles(directory, "*.nupkg").First();
+
+ XDocument document;
+
+ using(var file = File.OpenRead(packageZip))
+ using (var archive = new ZipArchive(file, ZipArchiveMode.Read, false))
+ {
+ var entry = archive.Entries.First(e => System.IO.Path.GetExtension(e.FullName) == ".nuspec");
+ using(var nuspec = entry.Open())
+ document = XDocument.Load(nuspec);
+ }
+
+ if (document == null)
+ throw new Exception($"No nuspec found in {packageZip}");
+
+ var ns = document.Root.Name.Namespace;
+ var metadata = document.Root.Element(ns + "metadata");
+
+ if (metadata == null)
+ throw new Exception($"No metadata found in nuspec document in {packageZip}");
+
+ Id = metadata.Element(ns + "id").Value.Trim();
+ Version = metadata.Element(ns + "version").Value.Trim();
+ Path = directory;
+
+ FrameworkVersions = Directory.EnumerateDirectories(System.IO.Path.Combine(Path, "lib"))
+ .Select(d => NuGetFramework.ParseFolder(System.IO.Path.GetFileName(d)))
+ .ToList();
+ }
+
+ public string Id { get; }
+ public string Version { get; }
+ public string Path { get; }
+ public IReadOnlyList FrameworkVersions { get; }
+
+ public NuGetFramework GetNearest(string frameworkVersion)
+ {
+ var framework = NuGetFramework.Parse(frameworkVersion);
+ return Reducer.GetNearest(framework, FrameworkVersions);
+ }
+ }
+
+ public interface INuGetPackage
+ {
+ string Id { get; }
+
+ string Version { get; }
+
+ string Path { get; }
+
+ IReadOnlyList FrameworkVersions { get; }
+
+ NuGetFramework GetNearest(string frameworkVersion);
+ }
+}
diff --git a/src/Differ/README.md b/src/Differ/README.md
new file mode 100644
index 0000000..7e263c1
--- /dev/null
+++ b/src/Differ/README.md
@@ -0,0 +1,67 @@
+# Differ
+
+Compare and Diff assemblies from different sources.
+Useful for determining what changes are introduced across versions, and if any are _breaking_.
+
+Outputs differences in XML, Markdown or AsciiDoc.
+
+Run
+
+```bat
+dotnet run -- --help
+```
+
+to see the supported Assembly Providers and outputs:
+
+```bat
+Differ.exe [Options]
+
+Supported Assembly Providers:
+
+ assembly|
+ directory|
+ nuget|||[framework version]
+ github|/|||
+
+Options:
+ -t, --target=VALUE the assembly targets. Defaults to *all* assemblies
+ located by the provider
+ -f, --format=VALUE the format of the diff output. Supported formats
+ are xml, markdown, asciidoc. Defaults to xml
+ -o, --output=VALUE the output directory. Defaults to current directory
+ -h, -?, --help show this message and exit
+```
+
+Differ uses [JustAssembly, licensed under Apache 2.0](https://github.com/telerik/JustAssembly)
+
+#### Examples:
+
+Diff between two local assemblies:
+
+```bat
+dotnet run -- "assembly|C:\6.1.0\Nest.dll" "assembly|C:\6.2.0\Nest.dll"
+```
+
+Diff between all assemblies in directories, matched by name:
+
+```bat
+dotnet run -- "directory|C:\6.1.0" "directory|C:\6.2.0"
+```
+
+Diff NuGet packages:
+
+```bat
+dotnet run -- "nuget|NEST|6.1.0|net46" "nuget|NEST|6.2.0|net46"
+```
+
+Diff GitHub commits:
+
+```bat
+dotnet run -- "github|elastic/elasticsearch-net|6.1.0|cmd /C call build.bat skiptests skipdocs|build\output\Nest\net46" "github|elastic/elasticsearch-net|6.2.0|cmd /C call build.bat skiptests skipdocs|build\output\Nest\net46"
+```
+
+Any of the above can be mixed. For example, to compare GitHub HEAD against last NuGet package, and output in Markdown
+
+```bat
+dotnet run -- --format markdown "nuget|NEST|6.2.0|net46" "github|elastic/elasticsearch-net|HEAD|cmd /C call build.bat skiptests skipdocs|build\output\Nest\net46"
+```
\ No newline at end of file
diff --git a/src/Differ/lib/JustAssembly.API.dll b/src/Differ/lib/JustAssembly.API.dll
new file mode 100644
index 0000000..13f963a
Binary files /dev/null and b/src/Differ/lib/JustAssembly.API.dll differ
diff --git a/src/Differ/lib/JustAssembly.API.pdb b/src/Differ/lib/JustAssembly.API.pdb
new file mode 100644
index 0000000..a9801ab
Binary files /dev/null and b/src/Differ/lib/JustAssembly.API.pdb differ
diff --git a/src/Differ/lib/JustAssembly.Core.dll b/src/Differ/lib/JustAssembly.Core.dll
new file mode 100644
index 0000000..5d0a5a9
Binary files /dev/null and b/src/Differ/lib/JustAssembly.Core.dll differ
diff --git a/src/Differ/lib/JustAssembly.Core.pdb b/src/Differ/lib/JustAssembly.Core.pdb
new file mode 100644
index 0000000..6ccc3cd
Binary files /dev/null and b/src/Differ/lib/JustAssembly.Core.pdb differ
diff --git a/src/Differ/lib/JustAssembly.Infrastructure.dll b/src/Differ/lib/JustAssembly.Infrastructure.dll
new file mode 100644
index 0000000..96b2f92
Binary files /dev/null and b/src/Differ/lib/JustAssembly.Infrastructure.dll differ
diff --git a/src/Differ/lib/JustAssembly.Infrastructure.pdb b/src/Differ/lib/JustAssembly.Infrastructure.pdb
new file mode 100644
index 0000000..4ee6766
Binary files /dev/null and b/src/Differ/lib/JustAssembly.Infrastructure.pdb differ
diff --git a/src/Differ/lib/JustDecompile.External.JustAssembly.dll b/src/Differ/lib/JustDecompile.External.JustAssembly.dll
new file mode 100644
index 0000000..4c2f469
Binary files /dev/null and b/src/Differ/lib/JustDecompile.External.JustAssembly.dll differ
diff --git a/src/Differ/lib/JustDecompile.External.JustAssembly.pdb b/src/Differ/lib/JustDecompile.External.JustAssembly.pdb
new file mode 100644
index 0000000..b614c46
Binary files /dev/null and b/src/Differ/lib/JustDecompile.External.JustAssembly.pdb differ
diff --git a/src/Differ/lib/JustDecompiler.dll b/src/Differ/lib/JustDecompiler.dll
new file mode 100644
index 0000000..0e66457
Binary files /dev/null and b/src/Differ/lib/JustDecompiler.dll differ
diff --git a/src/Differ/lib/JustDecompiler.pdb b/src/Differ/lib/JustDecompiler.pdb
new file mode 100644
index 0000000..3aab668
Binary files /dev/null and b/src/Differ/lib/JustDecompiler.pdb differ
diff --git a/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Mdb.dll b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Mdb.dll
new file mode 100644
index 0000000..15d2f7e
Binary files /dev/null and b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Mdb.dll differ
diff --git a/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Mdb.pdb b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Mdb.pdb
new file mode 100644
index 0000000..f00400f
Binary files /dev/null and b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Mdb.pdb differ
diff --git a/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Pdb.dll b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Pdb.dll
new file mode 100644
index 0000000..9f13de8
Binary files /dev/null and b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Pdb.dll differ
diff --git a/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Pdb.pdb b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Pdb.pdb
new file mode 100644
index 0000000..2c4b965
Binary files /dev/null and b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.Pdb.pdb differ
diff --git a/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.dll b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.dll
new file mode 100644
index 0000000..b825156
Binary files /dev/null and b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.dll differ
diff --git a/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.pdb b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.pdb
new file mode 100644
index 0000000..bc6b9b9
Binary files /dev/null and b/src/Differ/lib/Telerik.JustDecompile.Mono.Cecil.pdb differ
diff --git a/src/Elastic.Abstractions.sln b/src/Elastic.Abstractions.sln
index d46c07d..53758d8 100644
--- a/src/Elastic.Abstractions.sln
+++ b/src/Elastic.Abstractions.sln
@@ -37,6 +37,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Managed.Example", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nest.TypescriptExporter", "Nest.TypescriptExporter\Nest.TypescriptExporter.csproj", "{C05F7B36-EEF7-4BCD-86A2-F5F1BB8CFEB9}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Differ", "Differ\Differ.csproj", "{346B9887-CBF1-458F-99F4-D67F13C19623}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -92,5 +94,9 @@ Global
{C05F7B36-EEF7-4BCD-86A2-F5F1BB8CFEB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C05F7B36-EEF7-4BCD-86A2-F5F1BB8CFEB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C05F7B36-EEF7-4BCD-86A2-F5F1BB8CFEB9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {346B9887-CBF1-458F-99F4-D67F13C19623}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {346B9887-CBF1-458F-99F4-D67F13C19623}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {346B9887-CBF1-458F-99F4-D67F13C19623}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {346B9887-CBF1-458F-99F4-D67F13C19623}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal