Add [StackTraceHidden] to MTP and MSTest adapter test execution plumbing#8854
Merged
Evangelink merged 1 commit intoJun 5, 2026
Merged
Conversation
Follow-up to PR microsoft#8853 (addressed assertion internals) and continues addressing @Youssef1313's feedback on microsoft#8826: use [StackTraceHidden] instead of trying to filter stack frames manually at the rendering layer. Annotates the test execution plumbing types that always sit between the user test method and the top of a failure stack trace, so the runtime omits their frames from the public StackTrace surface: Microsoft.Testing.Platform hosts (Microsoft.Testing.Platform.Hosts): - CommonHost (abstract base) - ConsoleTestHost - ServerTestHost - TestHostControlledHost - TestHostControllersTestHost VSTest bridge (Microsoft.Testing.Extensions.VSTestBridge): - VSTestBridgedTestFrameworkBase - SynchronizedSingleSessionVSTestBridgedTestFramework MSTest adapter (Microsoft.VisualStudio.TestPlatform.MSTestAdapter / MSTest.TestAdapter): - MSTestBridgedTestFramework - MSTestExecutor - TestExecutionManager - UnitTestRunner - TestMethodRunner - TestMethodInfo (partial; applies to all sibling partials via attribute merging) Scope rationale: kept narrow to types explicitly mentioned in microsoft#8826 plus the immediate execution wrappers between user code and reporter (per rubber-duck review). Broader sweeps (e.g. all internals in Microsoft.Testing.Platform) are intentionally avoided to (a) preserve extension authors' ability to debug their own extension code and (b) avoid hiding frames that may carry genuine diagnostic value. Notes / out of scope: - Compiler-generated MoveNext/closure frames inside annotated async/iterator methods may still leak — known [StackTraceHidden] limitation; the rendering-layer filter proposed in microsoft#8826 may still be needed to handle those plus types we don't own. - Public exception types and the TestApplication public entry point are intentionally not annotated. Build: .\build.cmd -c Debug succeeds with 0 warnings / 0 errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies [StackTraceHidden] to key Microsoft.Testing.Platform (MTP) host and MSTest adapter execution “plumbing” types so that user-facing failure stack traces omit these framework frames, reducing noise between the user’s test/production code and the failure site.
Changes:
- Annotate MTP host implementations (and their common base) with
[StackTraceHidden]. - Annotate VSTest bridge base types used in the bridged execution path with
[StackTraceHidden]. - Annotate MSTest adapter execution types that commonly appear in failure stack traces with
[StackTraceHidden].
Show a summary per file
| File | Description |
|---|---|
| src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs | Hide common host base frames from stack traces. |
| src/Platform/Microsoft.Testing.Platform/Hosts/ConsoleTestHost.cs | Hide console host frames from stack traces. |
| src/Platform/Microsoft.Testing.Platform/Hosts/ServerTestHost.cs | Hide server host frames from stack traces. |
| src/Platform/Microsoft.Testing.Platform/Hosts/TestHostControlledHost.cs | Hide controlled-host wrapper frames from stack traces. |
| src/Platform/Microsoft.Testing.Platform/Hosts/TestHostControllersTestHost.cs | Hide controller host frames from stack traces. |
| src/Platform/Microsoft.Testing.Extensions.VSTestBridge/VSTestBridgedTestFrameworkBase.cs | Hide bridged framework base frames from stack traces. |
| src/Platform/Microsoft.Testing.Extensions.VSTestBridge/SynchronizedSingleSessionVSTestAndTestAnywhereAdapter.cs | Hide single-session bridged framework frames from stack traces. |
| src/Adapter/MSTestAdapter.PlatformServices/Execution/UnitTestRunner.cs | Hide adapter unit test runner frames from stack traces. |
| src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.cs | Hide adapter test-method runner frames from stack traces. |
| src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.cs | Hide adapter test-method info frames from stack traces (via partial). |
| src/Adapter/MSTestAdapter.PlatformServices/Execution/TestExecutionManager.cs | Hide adapter execution manager frames from stack traces. |
| src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestExecutor.cs | Hide MSTest executor frames from stack traces. |
| src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestBridgedTestFramework.cs | Hide MSTest bridged framework frames from stack traces. |
Copilot's findings
- Files reviewed: 13/13 changed files
- Comments generated: 0
azat-msft
approved these changes
Jun 5, 2026
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.
Follow-up to #8853 (assertion internals) and continues addressing @Youssef1313's feedback on #8826:
This PR annotates the MTP and MSTest adapter test execution plumbing types that always sit between the user test method and the top of a failure stack trace, so the runtime omits their frames from the public
StackTracesurface.Types annotated with
[StackTraceHidden]Microsoft.Testing.Platform hosts (
Microsoft.Testing.Platform.Hosts):CommonHost(abstract base)ConsoleTestHostServerTestHostTestHostControlledHostTestHostControllersTestHostVSTest bridge (
Microsoft.Testing.Extensions.VSTestBridge):VSTestBridgedTestFrameworkBaseSynchronizedSingleSessionVSTestBridgedTestFrameworkMSTest adapter (
Microsoft.VisualStudio.TestPlatform.MSTestAdapter/MSTest.TestAdapter):MSTestBridgedTestFrameworkMSTestExecutorTestExecutionManagerUnitTestRunnerTestMethodRunnerTestMethodInfo(annotated on one partial; applies to all sibling partials via attribute merging)Scope rationale
Kept narrow to types explicitly mentioned in #8826 plus the immediate execution wrappers between user code and reporter. Broader sweeps (e.g. all internals in
Microsoft.Testing.Platform) are intentionally avoided to:Notes / out of scope
MoveNext/ closure frames inside annotated async/iterator methods may still leak — a known[StackTraceHidden]runtime limitation. The rendering-layer filter proposed in Filter MTP/MSTest internal stack frames from terminal failure output #8826 may still be needed to handle those plus frames in types we don't own (e.g. VSTest object model).TestApplicationpublic entry point are intentionally not annotated.Validation
.\build.cmd -c Debugsucceeds with 0 warnings / 0 errors.