From 17ead0b2587d497f84babc16f302fc212e56e188 Mon Sep 17 00:00:00 2001 From: jnm2 Date: Mon, 17 Nov 2025 15:48:05 -0500 Subject: [PATCH 1/2] Align fast csproj parser with SDK update which removed global:: from generated global usings file --- .../FastCsprojCompilationParserTests.cs | 14 +++++++------- tools/ExampleTester/FastCsprojCompilationParser.cs | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs b/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs index c07faaf74..9e850cfb5 100644 --- a/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs +++ b/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs @@ -209,13 +209,13 @@ public static void ParsesImplicitUsings([Values("true", "enable", "false", "disa source.FilePath.ShouldBe("Test.GlobalUsings.g.cs"); source.GetText().ToString().ShouldBe(""" // - 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; """); } diff --git a/tools/ExampleTester/FastCsprojCompilationParser.cs b/tools/ExampleTester/FastCsprojCompilationParser.cs index 51c7f1098..0592a5858 100644 --- a/tools/ExampleTester/FastCsprojCompilationParser.cs +++ b/tools/ExampleTester/FastCsprojCompilationParser.cs @@ -134,13 +134,13 @@ public static CsprojParseResult ParseCsproj(XDocument csprojDocument, string fil { generatedSources.Add(SyntaxFactory.ParseSyntaxTree(""" // - 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, From 47ef6461a82479960281493d9895c0d69c03c3c8 Mon Sep 17 00:00:00 2001 From: jnm2 Date: Mon, 17 Nov 2025 15:49:02 -0500 Subject: [PATCH 2/2] Make test failures show the exact difference on SDK generated code --- .../FastCsprojCompilationParserTests.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs b/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs index 9e850cfb5..db4d1f94f 100644 --- a/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs +++ b/tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs @@ -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) @@ -216,7 +221,7 @@ public static void ParsesImplicitUsings([Values("true", "enable", "false", "disa global using System.Net.Http; global using System.Threading; global using System.Threading.Tasks; - + """); } else