Skip to content

Report test extension load failures to the user - #16383

Closed
Jakub Jareš (nohwnd) wants to merge 1 commit into
microsoft:mainfrom
nohwnd:pilot/tell-the-user-when-a-test-extension-fail-20260818140443
Closed

Report test extension load failures to the user#16383
Jakub Jareš (nohwnd) wants to merge 1 commit into
microsoft:mainfrom
nohwnd:pilot/tell-the-user-when-a-test-extension-fail-20260818140443

Conversation

@nohwnd

Copy link
Copy Markdown
Member

TestPluginDiscoverer only told the user about a failing extension file when Assembly.Load threw FileLoadException. Two other paths were silent and wrote to EqtTrace only: the general Exception handler in GetTestExtensionsFromFiles, which is the one that catches the FileNotFoundException thrown when an extension or one of its dependencies cannot be found, and the ReflectionTypeLoadException handler in GetTestExtensionsFromAssembly, which carries on with a half-loaded type list.

So an adapter that half-loaded gave the user fewer tests than expected, or a hang, with no way to find out why short of re-running with /diag. Both now report through TestSessionMessageLogger using the existing, already localised FailedToLoadAdapaterFile message, so no .resx or .xlf change is needed.

Scanning stays best effort. Nothing throws and nothing aborts, a partially loaded assembly is still scanned for every extension type, each file is reported once per run, and the two C++ UWP adapters that are probed speculatively when no extension was found are not reported because they are absent everywhere except UWP.

This is the diagnostic half of #15577. The packaging cause behind the report on that issue, the missing net462 companion assemblies, was fixed separately in #15739 and shipped in 18.9.0, so this does not close #15577 on its own.

Verified: build.cmd -c Release compiles clean, Microsoft.TestPlatform.Common.UnitTests passes on net481 and net11.0, and a locally built vstest.console reproduces both failure modes end to end.

Related to #15577

🤖

🤖

TestPluginDiscoverer only told the user about a failing extension file when
Assembly.Load threw FileLoadException. The general Exception handler, which is
the one that catches the FileNotFoundException thrown when an extension or one
of its dependencies is missing, and the ReflectionTypeLoadException handler for
an assembly that loads but whose types do not, both wrote to EqtTrace only. A
user whose adapter half-loaded got fewer tests than expected, or a hang, and
could only find out why by re-running with /diag.

Both now report through TestSessionMessageLogger with the existing, already
localised FailedToLoadAdapaterFile message. Scanning stays best effort: nothing
throws, nothing aborts, and a partially loaded assembly is still scanned for
every extension type. Each file is reported once per run, and the two C++ UWP
adapters that are probed speculatively when no extension was found are not
reported, since they are absent everywhere except UWP.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 18, 2026 14:32

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

Improves extension/adapters discovery diagnostics in Microsoft.TestPlatform.Common by surfacing previously trace-only extension load failures to end users via TestSessionMessageLogger, while keeping discovery best-effort.

Changes:

  • Centralized extension-load warning reporting and de-duplicated warnings per failing extension file.
  • Reported additional failure paths (general Exception during load and ReflectionTypeLoadException during type enumeration) as user-visible warnings.
  • Added unit tests validating warning emission, de-duplication, and continued scanning on partial type load.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs Adds warning reporting + de-duplication and extends reporting to additional failure paths while preserving best-effort scanning.
test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs Adds coverage for the new warning/reporting behavior (missing file, speculative probes, partial type load).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +29 to +32
/// <summary>
/// Files we already told the user about, so that a file that fails for every extension type is
/// reported once per run instead of once per scan.
/// </summary>
@nohwnd

Copy link
Copy Markdown
Member Author

Closing this one: #16382 is the same work and has more of it. Same two files, plus the TestPluginCache change this one is missing.

Both were opened three minutes apart by my automation, which was building a second pull request for work that already had one. That is fixed.

🤖

@nohwnd
Jakub Jareš (nohwnd) deleted the pilot/tell-the-user-when-a-test-extension-fail-20260818140443 branch August 19, 2026 10:42
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.

STJ migration: DesignMode/wrapper communication hangs during test execution

2 participants