Skip to content

Commit 4e57448

Browse files
authored
Merge pull request #1474 from dotnet/follow_sdk_update_to_fix_ci
Fix draft-v8 CI by following SDK changes in generated global usings file
2 parents 7378b6f + 47ef646 commit 4e57448

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

tools/ExampleTester.Tests/FastCsprojCompilationParserTests.cs

Lines changed: 17 additions & 12 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)
@@ -209,14 +214,14 @@ public static void ParsesImplicitUsings([Values("true", "enable", "false", "disa
209214
source.FilePath.ShouldBe("Test.GlobalUsings.g.cs");
210215
source.GetText().ToString().ShouldBe("""
211216
// <auto-generated/>
212-
global using global::System;
213-
global using global::System.Collections.Generic;
214-
global using global::System.IO;
215-
global using global::System.Linq;
216-
global using global::System.Net.Http;
217-
global using global::System.Threading;
218-
global using global::System.Threading.Tasks;
219-
217+
global using System;
218+
global using System.Collections.Generic;
219+
global using System.IO;
220+
global using System.Linq;
221+
global using System.Net.Http;
222+
global using System.Threading;
223+
global using System.Threading.Tasks;
224+
220225
""");
221226
}
222227
else

tools/ExampleTester/FastCsprojCompilationParser.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ public static CsprojParseResult ParseCsproj(XDocument csprojDocument, string fil
134134
{
135135
generatedSources.Add(SyntaxFactory.ParseSyntaxTree("""
136136
// <auto-generated/>
137-
global using global::System;
138-
global using global::System.Collections.Generic;
139-
global using global::System.IO;
140-
global using global::System.Linq;
141-
global using global::System.Net.Http;
142-
global using global::System.Threading;
143-
global using global::System.Threading.Tasks;
137+
global using System;
138+
global using System.Collections.Generic;
139+
global using System.IO;
140+
global using System.Linq;
141+
global using System.Net.Http;
142+
global using System.Threading;
143+
global using System.Threading.Tasks;
144144
145145
""",
146146
parseOptions,

0 commit comments

Comments
 (0)