diff --git a/Directory.Packages.props b/Directory.Packages.props index eb4f98a1fd..0d533467dd 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -100,14 +100,14 @@ - + - - - - - + + + + + diff --git a/TUnit.Mocks.SourceGenerator.Tests/SnapshotTestBase.cs b/TUnit.Mocks.SourceGenerator.Tests/SnapshotTestBase.cs index 470fee94ac..5bc99bd07e 100644 --- a/TUnit.Mocks.SourceGenerator.Tests/SnapshotTestBase.cs +++ b/TUnit.Mocks.SourceGenerator.Tests/SnapshotTestBase.cs @@ -68,11 +68,21 @@ protected static string[] RunGenerator( } return runResult.GeneratedTrees - .OrderBy(t => t.FilePath, StringComparer.Ordinal) + .OrderBy(t => GetGeneratedTreeSortKey(t.FilePath), StringComparer.Ordinal) .Select(t => t.GetText().ToString()) .ToArray(); } + private static string GetGeneratedTreeSortKey(string filePath) + { + var normalizedPath = filePath.Replace('\\', '/'); + var fileNameStart = normalizedPath.LastIndexOf('/'); + + return fileNameStart >= 0 + ? normalizedPath[(fileNameStart + 1)..] + : normalizedPath; + } + /// /// Compiles the given source into an in-memory assembly and returns it as a MetadataReference. /// Useful for simulating external assemblies in tests.