diff --git a/eng/Versions.props b/eng/Versions.props
index 4624793f67db8151826369c5a975455992e8b2bb..3d20cfbda04ada9f0fc31b16728ab2582647646f 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -30,6 +30,7 @@
0.9.3
0.11.1
2.0.273-beta
+ 1.4.4
17.144.28413-buildid7983345
8.0.2
8.0.0
diff --git a/src/Test/Utilities/Portable/Assert/AssertEx.cs b/src/Test/Utilities/Portable/Assert/AssertEx.cs
index 88c71b833bf58eac9eff69ef8b0577fb10490a3d..b48c4920d883a3f6447a884924eb4ae59897483f 100644
--- a/src/Test/Utilities/Portable/Assert/AssertEx.cs
+++ b/src/Test/Utilities/Portable/Assert/AssertEx.cs
@@ -9,6 +9,9 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
+using DiffPlex;
+using DiffPlex.DiffBuilder;
+using DiffPlex.DiffBuilder.Model;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
@@ -210,6 +213,48 @@ public static void Equal(ImmutableArray expected, ImmutableArray actual
Assert.True(false, assertMessage);
}
+ ///
+ /// Asserts that two strings are equal, and prints a diff between the two if they are not.
+ ///
+ /// The expected string. This is presented as the "baseline/before" side in the diff.
+ /// The actual string. This is presented as the changed or "after" side in the diff.
+ /// The message to precede the diff, if the values are not equal.
+ public static void EqualOrDiff(string expected, string actual, string message = null)
+ {
+ if (expected == actual)
+ {
+ return;
+ }
+
+ var diffBuilder = new InlineDiffBuilder(new Differ());
+ var diff = diffBuilder.BuildDiffModel(expected, actual, ignoreWhitespace: false);
+ var messageBuilder = new StringBuilder();
+ messageBuilder.AppendLine(
+ string.IsNullOrEmpty(message)
+ ? "Actual and expected values differ. Expected shown in baseline of diff:"
+ : message);
+
+ foreach (var line in diff.Lines)
+ {
+ switch (line.Type)
+ {
+ case ChangeType.Inserted:
+ messageBuilder.Append("+");
+ break;
+ case ChangeType.Deleted:
+ messageBuilder.Append("-");
+ break;
+ default:
+ messageBuilder.Append(" ");
+ break;
+ }
+
+ messageBuilder.AppendLine(line.Text);
+ }
+
+ Assert.True(false, messageBuilder.ToString());
+ }
+
public static void NotEqual(IEnumerable expected, IEnumerable actual, IEqualityComparer comparer = null, string message = null,
string itemSeparator = null, Func itemInspector = null)
{
diff --git a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj
index 260517afbba4d3109e386a35c546f4a2e9366829..5cceca0bb4b4f8a0aecd5443a266bd024c40f95a 100644
--- a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj
+++ b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj
@@ -92,6 +92,7 @@
+