From 15da70f0b6fbf8b93045a6febce4852bc5988e9c Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Tue, 15 Oct 2024 20:44:31 -0700 Subject: [PATCH] Add RunSettings: Explicit --- src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs | 4 +++- src/xunit.runner.visualstudio/Utility/RunSettings.cs | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs b/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs index 40ed91d..af02f0f 100644 --- a/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs +++ b/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs @@ -23,7 +23,9 @@ public class AssemblyRunInfo ConfigReader.Load(Assembly.Configuration, Assembly.AssemblyFileName, Assembly.ConfigFileName, configWarnings); runSettings.CopyTo(Assembly.Configuration); - Assembly.Configuration.ExplicitOption = runExplicitTests ? ExplicitOption.On : ExplicitOption.Off; + // The Test Explorer UI doesn't give the user the ability to specify this, so if we haven't come along + // and set it via the command line, we'll use our auto-calculation based on what we think the user wants + Assembly.Configuration.ExplicitOption ??= runExplicitTests ? ExplicitOption.On : ExplicitOption.Off; foreach (var warning in configWarnings) logger.LogWarning("{0}", warning); diff --git a/src/xunit.runner.visualstudio/Utility/RunSettings.cs b/src/xunit.runner.visualstudio/Utility/RunSettings.cs index 88d1313..9ff7c24 100644 --- a/src/xunit.runner.visualstudio/Utility/RunSettings.cs +++ b/src/xunit.runner.visualstudio/Utility/RunSettings.cs @@ -12,6 +12,7 @@ public class RunSettings public string? Culture { get; set; } public bool DesignMode { get; set; } = false; public bool? DiagnosticMessages { get; set; } + public ExplicitOption? Explicit { get; set; } public bool? FailSkips { get; set; } public bool? FailWarns { get; set; } public bool? InternalDiagnosticMessages { get; set; } @@ -44,6 +45,8 @@ public void CopyTo(TestAssemblyConfiguration configuration) }; if (DiagnosticMessages.HasValue) configuration.DiagnosticMessages = DiagnosticMessages; + if (Explicit.HasValue) + configuration.ExplicitOption = Explicit; if (FailSkips.HasValue) configuration.FailSkips = FailSkips; if (FailWarns.HasValue) @@ -102,6 +105,10 @@ public static RunSettings Parse(string? settingsXml) if (bool.TryParse(diagnosticMessagesString, out var diagnosticMessages)) result.DiagnosticMessages = diagnosticMessages; + var explicitString = xunitElement.Element(Constants.Xunit.Explicit)?.Value; + if (Enum.TryParse(explicitString, ignoreCase: true, out var @explicit)) + result.Explicit = @explicit; + var failSkipsString = xunitElement.Element(Constants.Xunit.FailSkips)?.Value; if (bool.TryParse(failSkipsString, out var failSkips)) result.FailSkips = failSkips; @@ -258,6 +265,7 @@ public static class Xunit public const string AppDomain = nameof(AppDomain); public const string Culture = nameof(Culture); public const string DiagnosticMessages = nameof(DiagnosticMessages); + public const string Explicit = nameof(Explicit); public const string FailSkips = nameof(FailSkips); public const string FailWarns = nameof(FailWarns); public const string InternalDiagnosticMessages = nameof(InternalDiagnosticMessages);