Skip to content

Commit

Permalink
Fix error when passing in a null run settings value on .net 6 SDKs
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Aug 4, 2023
1 parent b9a4f2b commit f46a316
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Testing;
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal partial class TestRunner(ILoggerFactory loggerFactory)
{
/// <summary>
/// A default value for run settings. While the vstest console included with newer SDKs does
/// support passing in a null run settings value, the vstest console in older SDKs (.net 6 for example)
/// will throw if we pass a null value. So for our default we hardcode an empty XML configuration.
/// TODO - Support configuring run settings - https://github.com/dotnet/vscode-csharp/issues/5719
/// </summary>
private static readonly string s_defaultRunSettings = "<RunSettings/>";
private readonly ILogger _logger = loggerFactory.CreateLogger<TestRunner>();

public async Task RunTestsAsync(
Expand Down Expand Up @@ -53,13 +60,12 @@ private static void RunTests(
if (attachDebugger)
{
// When we want to debug tests we need to use a custom test launcher so that we get called back with the process to attach to.
vsTestConsoleWrapper.RunTestsWithCustomTestHost(testCases, runSettings: null, handler, new DebugTestHostLauncher(progress, clientLanguageServerManager));
vsTestConsoleWrapper.RunTestsWithCustomTestHost(testCases, runSettings: s_defaultRunSettings, handler, new DebugTestHostLauncher(progress, clientLanguageServerManager));
}
else
{
// The async APIs for vs test are broken (current impl ends up just hanging), so we must use the sync API instead.
// TODO - run settings. https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1799066/
vsTestConsoleWrapper.RunTests(testCases, runSettings: null, handler);
vsTestConsoleWrapper.RunTests(testCases, runSettings: s_defaultRunSettings, handler);
}
}
}

0 comments on commit f46a316

Please sign in to comment.