Skip to content

Consider unifying adapter settings-exception handling (AdapterRunSettingsException/InvalidRunSettingsException vs AdapterSettingsException catch topology) #9629

Description

Context

This is a deliberately-deferred design follow-up from the VSTest-object-model decoupling of MSTestAdapter.PlatformServices (the SettingsException neutralization in Phase 6e-4a).

Today the adapter has a two-tier settings-exception topology, which the decoupling work preserved byte-for-byte rather than changing:

  • AdapterSettingsException — thrown for invalid MSTest settings values (e.g. <Parallelize><Scope>/Workers). It is caught by MSTestDiscovererHelpers.InitializeDiscovery (which wraps MSTestSettings.PopulateSettings), which logs the error and returns false → discovery reports "no tests" / execution bails gracefully.
  • InvalidRunSettingsException (introduced in 6e-4a as the neutral replacement for the VSTest SettingsException; derives directly from Exception) — thrown for structural runsettings errors (bad attribute, unexpected element, malformed <AssemblyResolution>, wrong root). It is not caught by that handler and escapes to the MSTestExecutor/MSTestDiscoverer boundary, propagating to the host — exactly as the VSTest SettingsException did historically.

The distinct exception (not derived from AdapterSettingsException) is intentional: it keeps where a settings-format error surfaces identical to the pre-decoupling behavior. An expert review during 6e-4a confirmed that reusing AdapterSettingsException for the structural-error sites would have made a malformed <AssemblyResolution> block newly caught (log + "no tests") instead of escaping — an observable behavior change.

The idea to consider (separately)

Unifying these two onto a single settings-exception model (so all settings-format errors are handled consistently — e.g. all caught + logged early, or all escaping) is arguably a cleaner design. But it is a deliberate behavior change, not a mechanical refactor, so it was kept out of the decoupling PRs.

If pursued, it needs its own review + reasoning:

  • Decide the desired single behavior (caught-and-logged vs escape-to-host) for all settings-format errors.
  • Update the throw sites (RunSettingsUtilities, TestRunParameters, MSTestAdapterSettings) and the MSTestDiscovererHelpers.InitializeDiscovery catch accordingly.
  • Update/repurpose the …BailOutOnSettingsException tests, which currently pin the two-tier topology.

Scope

Design/behavior change only — no functional urgency. Filed so the thought isn't lost.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions