Skip to content

Commit 47ef646

Browse files
committed
Make test failures show the exact difference on SDK generated code
1 parent 17ead0b commit 47ef646

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ private static void CompareMSBuildWorkspaceCompilation(string csprojContents, Cs
4545
Path.GetFileName(tree.FilePath).EndsWith(ending, StringComparison.OrdinalIgnoreCase)))
4646
.ToImmutableArray();
4747

48+
// Assert that the generated files have the same names in the same order
4849
result.GeneratedSources.SequenceEqual(sanitizedSyntaxTrees, (a, b) =>
49-
Path.GetFileName(a.FilePath).Equals(Path.GetFileName(b.FilePath), StringComparison.OrdinalIgnoreCase)
50-
&& a.Options.Equals(b.Options)
51-
&& a.GetText().ToString() == b.GetText().ToString())
52-
.ShouldBeTrue();
50+
Path.GetFileName(a.FilePath).Equals(Path.GetFileName(b.FilePath), StringComparison.OrdinalIgnoreCase));
51+
52+
// Assert that the files have the same parse options and contents
53+
foreach (var (fastGenerated, msbuildGenerated) in result.GeneratedSources.Zip(sanitizedSyntaxTrees))
54+
{
55+
fastGenerated.Options.ShouldBe(msbuildGenerated.Options);
56+
fastGenerated.GetText().ToString().ShouldBe(msbuildGenerated.GetText().ToString());
57+
}
5358
}
5459

5560
private static Compilation GetMSBuildWorkspaceCompilation(string csprojContents)
@@ -216,7 +221,7 @@ public static void ParsesImplicitUsings([Values("true", "enable", "false", "disa
216221
global using System.Net.Http;
217222
global using System.Threading;
218223
global using System.Threading.Tasks;
219-
224+
220225
""");
221226
}
222227
else

0 commit comments

Comments
 (0)