Skip to content

Commit 13c8988

Browse files
authored
Remove extraneous support in the test runner generator for referencing corelib directly. (#62154)
1 parent b5bb3c9 commit 13c8988

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/tests/Common/XUnitWrapperGenerator/OptionsHelper.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ namespace XUnitWrapperGenerator;
66

77
public static class OptionsHelper
88
{
9-
private const string ReferenceSystemPrivateCoreLibOption = "build_property.ReferenceSystemPrivateCoreLib";
109
private const string IsMergedTestRunnerAssemblyOption = "build_property.IsMergedTestRunnerAssembly";
1110
private const string PriorityOption = "build_property.Priority";
1211
private const string RuntimeFlavorOption = "build_property.RuntimeFlavor";
@@ -29,8 +28,6 @@ private static bool GetBoolOption(this AnalyzerConfigOptions options, string key
2928
? result : 0;
3029
}
3130

32-
internal static bool ReferenceSystemPrivateCoreLib(this AnalyzerConfigOptions options) => options.GetBoolOption(ReferenceSystemPrivateCoreLibOption);
33-
3431
internal static bool IsMergedTestRunnerAssembly(this AnalyzerConfigOptions options) => options.GetBoolOption(IsMergedTestRunnerAssemblyOption);
3532

3633
internal static int? Priority(this AnalyzerConfigOptions options) => options.GetIntOption(PriorityOption);

src/tests/Common/XUnitWrapperGenerator/XUnitWrapperGenerator.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,16 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
9898
return;
9999
}
100100

101-
bool referenceCoreLib = configOptions.GlobalOptions.ReferenceSystemPrivateCoreLib();
102-
103101
bool isMergedTestRunnerAssembly = configOptions.GlobalOptions.IsMergedTestRunnerAssembly();
104102

105103
// TODO: add error (maybe in MSBuild that referencing CoreLib directly from a merged test runner is not supported)
106-
if (isMergedTestRunnerAssembly && !referenceCoreLib)
104+
if (isMergedTestRunnerAssembly)
107105
{
108106
context.AddSource("FullRunner.g.cs", GenerateFullTestRunner(methods, aliasMap, assemblyName));
109107
}
110108
else
111109
{
112-
string consoleType = referenceCoreLib ? "Internal.Console" : "System.Console";
110+
string consoleType = "System.Console";
113111
context.AddSource("SimpleRunner.g.cs", GenerateStandaloneSimpleTestRunner(methods, aliasMap, consoleType));
114112
}
115113
});
@@ -144,7 +142,7 @@ private static string GenerateStandaloneSimpleTestRunner(ImmutableArray<ITestInf
144142
builder.AppendLine(string.Join("\n", aliasMap.Values.Where(alias => alias != "global").Select(alias => $"extern alias {alias};")));
145143
builder.AppendLine("try {");
146144
builder.AppendLine(string.Join("\n", testInfos.Select(m => m.GenerateTestExecution(reporter))));
147-
builder.AppendLine($"}} catch(System.Exception ex) {{ {consoleType}.WriteLine(ex.ToString()); return 101; }}");
145+
builder.AppendLine("} catch(System.Exception ex) { System.Console.WriteLine(ex.ToString()); return 101; }");
148146
builder.AppendLine("return 100;");
149147
return builder.ToString();
150148
}

0 commit comments

Comments
 (0)