Skip to content

Report raw invalid value for the remaining RunConfiguration bool settings - #16296

Closed
Jakub Jareš (nohwnd) wants to merge 2 commits into
microsoft:mainfrom
nohwnd:nohwnd-16271-followup-fixes
Closed

Report raw invalid value for the remaining RunConfiguration bool settings#16296
Jakub Jareš (nohwnd) wants to merge 2 commits into
microsoft:mainfrom
nohwnd:nohwnd-16271-followup-fixes

Conversation

@nohwnd

Copy link
Copy Markdown
Member

More follow-ups from the review on #16271, split out from #16295 so each PR stays focused.

Two RunConfiguration bool settings had the same bug #16295 fixes for IsTargetPlatformInferred: an invalid <DisableSharedTestHost> or <SkipDefaultAdapters> value threw a SettingsException that reported the parsed bool (always False) instead of the text the user actually wrote. Both report the raw value now, matching CreateNoNewWindow, and each has a test that asserts the full message.

Also fixed the forced-x64 verbose trace in DotnetTestHostManager: it still called the flag IsDefaultTargetArchitecture and misspelled architecture as architecure. The value comes from IsTargetPlatformInferred now, so the trace says that.

Verified locally in Release: ObjectModel.UnitTests (210, includes the two new ones) and TestHostProvider.UnitTests (114) pass.

🤖

…ings

More follow-ups from the review on microsoft#16271.

DisableSharedTestHost and SkipDefaultAdapters had the same bug as
IsTargetPlatformInferred: the SettingsException reported the parsed bool
(always False) instead of the value the user wrote. Both report the raw text
now, and each has a test that locks in the message.

Also fix the forced-x64 verbose trace in DotnetTestHostManager. It still called
the flag IsDefaultTargetArchitecture and misspelled architecture as
"architecure". The value comes from IsTargetPlatformInferred now, so it says
that instead.

🤖
Copilot AI review requested due to automatic review settings July 20, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves diagnostic clarity for RunConfiguration boolean parsing by ensuring invalid XML values are reported as the raw text provided by the user (instead of the parsed bool default), and aligns a related DotnetTestHostManager verbose trace message with the newer IsTargetPlatformInferred naming.

Changes:

  • Update RunConfiguration.FromXml to report the raw invalid value for DisableSharedTestHost and SkipDefaultAdapters.
  • Add unit tests asserting the full SettingsException message for invalid DisableSharedTestHost / SkipDefaultAdapters values.
  • Fix the forced-x64 verbose trace message wording in DotnetTestHostManager (flag name + “architecture” spelling).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/Microsoft.TestPlatform.ObjectModel.UnitTests/RunSettings/RunConfigurationTests.cs Adds message-asserting tests for invalid DisableSharedTestHost / SkipDefaultAdapters values.
src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs Updates verbose trace to reference IsTargetPlatformInferred and fixes “architecture” spelling in that message.
src/Microsoft.TestPlatform.ObjectModel/RunSettings/RunConfiguration.cs Changes invalid-bool exception formatting to include raw XML values for two RunConfiguration bool settings.

When <IsTargetPlatformInferred> holds a non-boolean value, the parse failure reported the parsed bool default (False) instead of the text the user actually wrote, so the error was misleading. Pass the raw element value to the SettingsException, matching the fix already applied to DisableSharedTestHost and SkipDefaultAdapters.

Strengthen the invalid-value test to assert the full exception message, consistent with the sibling tests.

🤖
Copilot AI review requested due to automatic review settings July 21, 2026 08:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines 1024 to 1034
case nameof(DisableSharedTestHost):
{
XmlRunSettingsUtilities.ThrowOnHasAttributes(reader);
string element = reader.ReadElementContentAsString();

bool boolValue;
if (!bool.TryParse(element, out boolValue))
{
throw new SettingsException(string.Format(CultureInfo.CurrentCulture,
Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, boolValue, elementName));
Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, element, elementName));
}
if (forceToX64)
{
EqtTrace.Verbose($"DotnetTestHostmanager: Forcing the search to x64 architecure, IsDefaultTargetArchitecture '{_isDefaultTargetArchitecture}' OS '{_platformEnvironment.OperatingSystem}' framework '{_targetFramework}'");
EqtTrace.Verbose($"DotnetTestHostmanager: Forcing the search to x64 architecture, IsTargetPlatformInferred '{_isDefaultTargetArchitecture}' OS '{_platformEnvironment.OperatingSystem}' framework '{_targetFramework}'");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants