Report test extension load failures to the user - #16383
Closed
Jakub Jareš (nohwnd) wants to merge 1 commit into
Closed
Report test extension load failures to the user#16383Jakub Jareš (nohwnd) wants to merge 1 commit into
Jakub Jareš (nohwnd) wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
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
Exceptionduring load andReflectionTypeLoadExceptionduring 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> |
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. 🤖 |
Jakub Jareš (nohwnd)
deleted the
pilot/tell-the-user-when-a-test-extension-fail-20260818140443
branch
August 19, 2026 10:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestPluginDiscovereronly told the user about a failing extension file whenAssembly.LoadthrewFileLoadException. Two other paths were silent and wrote toEqtTraceonly: the generalExceptionhandler inGetTestExtensionsFromFiles, which is the one that catches theFileNotFoundExceptionthrown when an extension or one of its dependencies cannot be found, and theReflectionTypeLoadExceptionhandler inGetTestExtensionsFromAssembly, 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 throughTestSessionMessageLoggerusing the existing, already localisedFailedToLoadAdapaterFilemessage, so no.resxor.xlfchange 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 Releasecompiles clean,Microsoft.TestPlatform.Common.UnitTestspasses on net481 and net11.0, and a locally builtvstest.consolereproduces both failure modes end to end.Related to #15577
🤖
🤖