Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ private static void CompareMSBuildWorkspaceCompilation(string csprojContents, Cs
Path.GetFileName(tree.FilePath).EndsWith(ending, StringComparison.OrdinalIgnoreCase)))
.ToImmutableArray();

// Assert that the generated files have the same names in the same order
result.GeneratedSources.SequenceEqual(sanitizedSyntaxTrees, (a, b) =>
Path.GetFileName(a.FilePath).Equals(Path.GetFileName(b.FilePath), StringComparison.OrdinalIgnoreCase)
&& a.Options.Equals(b.Options)
&& a.GetText().ToString() == b.GetText().ToString())
.ShouldBeTrue();
Path.GetFileName(a.FilePath).Equals(Path.GetFileName(b.FilePath), StringComparison.OrdinalIgnoreCase));

// Assert that the files have the same parse options and contents
foreach (var (fastGenerated, msbuildGenerated) in result.GeneratedSources.Zip(sanitizedSyntaxTrees))
{
fastGenerated.Options.ShouldBe(msbuildGenerated.Options);
fastGenerated.GetText().ToString().ShouldBe(msbuildGenerated.GetText().ToString());
}
}

private static Compilation GetMSBuildWorkspaceCompilation(string csprojContents)
Expand Down Expand Up @@ -209,14 +214,14 @@ public static void ParsesImplicitUsings([Values("true", "enable", "false", "disa
source.FilePath.ShouldBe("Test.GlobalUsings.g.cs");
source.GetText().ToString().ShouldBe("""
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Threading;
global using System.Threading.Tasks;

""");
}
else
Expand Down
14 changes: 7 additions & 7 deletions tools/ExampleTester/FastCsprojCompilationParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ public static CsprojParseResult ParseCsproj(XDocument csprojDocument, string fil
{
generatedSources.Add(SyntaxFactory.ParseSyntaxTree("""
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Threading;
global using System.Threading.Tasks;

""",
parseOptions,
Expand Down