Skip to content

Support MTP in language server test runs - #85271

Merged
JoeRobich merged 7 commits into
mainfrom
dev/jorobich/lsp-runtests-mtp
Sep 25, 2026
Merged

JoeRobich merged 7 commits into
mainfrom
dev/jorobich/lsp-runtests-mtp

Conversation

@JoeRobich

@JoeRobich JoeRobich commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

MTP is the future of .NET Test. The LSP should support it for running tests. Especially if Roslyns move to xUnit3 enables it for this repo.

Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: efbdf150-9a70-4a15-b692-4ad66f648d32
Copilot AI lite review requested due to automatic review settings September 11, 2026 20:58
@JoeRobich
JoeRobich requested review from a team as code owners September 11, 2026 20:58

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.

Copilot review overview

🟡 Changes recommended

Three moderate review findings remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 2 Medium severity

Open findings (2)
What changed in this PR

Adds MTP-based test discovery and execution to language-server test runs while retaining VSTest fallback support.

Changes:

  • Adds MTP discovery, execution, progress, and debugging.
  • Tracks project capabilities for runner selection.
  • Refactors VSTest handling and adds tests, dependencies, and documentation.
File Reviewed change
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​VsTestRunner.TestRunHandler.cs Handles VSTest run events.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​VsTestRunner.DiscoveryHandler.cs Handles VSTest discovery events.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​VsTestRunner.Discovery.cs Implements VSTest discovery.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​VsTestRunner.DebugTestHostLauncher.cs Integrates shared debugger attachment.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​VsTestRunner.cs Orchestrates VSTest execution.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​TestRunner.cs Replaced by split VSTest components.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​TestDebugger.cs Provides shared debugger attachment.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​RunTestsHandler.cs Selects MTP or VSTest; moderate issue (3 votes) concerns explicit runsettings-path handling.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​MtpTestRunner.Discovery.cs Implements MTP discovery and test matching.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​MtpTestRunner.cs Implements MTP execution; moderate issue (3 votes) concerns DOTNET_ROOT* normalization.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.csproj Adds MTP client sources.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​LanguageServer/​Handler/​Testing/​ProjectCapabilityManager.cs Tracks project testing capabilities.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​HostWorkspace/​LoadedProject.Target.cs Updates and removes cached capabilities.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​HostWorkspace/​LoadedProject.cs Propagates capability tracking.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​HostWorkspace/​LanguageServerProjectLoader.cs Wires capability tracking into project loading.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.UnitTests/​Testing/​RunTestsHandlerTests.cs Tests runner selection.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.UnitTests/​Testing/​ProjectCapabilityManagerTests.cs Tests capability caching.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.UnitTests/​Testing/​MtpTestRunnerTests.cs Tests MTP runner behavior.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.ProcessHost.UnitTests/​Testing/​RunTestsTests.cs Exercises test runs; moderate issue (1 vote) concerns verifying the MTP-specific execution path.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.ProcessHost.UnitTests/​Microsoft.CodeAnalysis.LanguageServer.ProcessHost.UnitTests.csproj Adds MSTest packages for materialized tests.
eng/​Packages.props Pins MTP and MSTest package versions.
.github/​instructions/​IDE.instructions.md Documents MTP/VSTest selection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 12, 2026 16:27

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.

Copilot review overview

🔵 Needs a closer look

Two moderate findings and one nit remain unresolved, covering runtime-root handling, retry-result filtering, and debugger-path coverage.

Review tier: Lite
Findings: 2 Medium severity

Open findings (2)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1041389b-067f-4d5f-82cf-0be548b778c3
Copilot AI review requested due to automatic review settings September 12, 2026 23:14

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.

Copilot review overview

🔵 Needs a closer look

MTP update callbacks can block the ordered transport loop and delay run completion.

Review tier: Lite
Findings: None

Resolved findings (2)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 346cc58a-1de1-47d0-97af-3a8afe7f27d0
Copilot AI review requested due to automatic review settings September 15, 2026 20: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.

Copilot review overview

🟡 Changes recommended

A critical MTP test-selection issue and moderate runtime/process-lifecycle issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite
Findings: 1 High severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity Add coverage for MTP debugger attachment

src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​Testing/​MtpTestRunner.cs:143

The new MTP path can return before running any tests when AttachAsync reports failure, and it now owns debugger attachment separately from the VSTest launcher. The process-host test exercises only AttachDebugger: false, and the unit tests do not cover either the successful attach request or the failure/early-return behavior. Please add coverage for both outcomes, including that a failed attach reports the failure and does not start the test run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7b143b04-2c37-45bc-b6b1-f6ca822c469e
Copilot AI review requested due to automatic review settings September 15, 2026 23:54

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.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate MTP session-state, cleanup, terminal-progress, and test-validation issues block approval.

Review tier: Lite
Findings: 1 High severity

Open (1)

Copilot AI review requested due to automatic review settings September 25, 2026 19:38

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.

Copilot review overview

🔵 Needs a closer look

Fix MTP session and debugger-failure handling, and strengthen the MTP integration assertion.

Review effort: Lite
Findings: None

Resolved since last review (1)

targetFrameworkManager.UpdateIdentifierForProject(_projectSystemProject.Id, newProjectInfo.TargetFrameworkIdentifier);
}

_projectCapabilityManager.UpdateCapabilities(_projectSystemProject.Id, newProjectInfo.ProjectCapabilities);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(not blocking) - @jasonmalinowski I wonder if we need something on the Project at some point that we could use for this. We've needed this side channel for TFMs before and now project capabilities. It seems like it would make sense if we were able to just associate these with the project instance instead.

Copilot AI review requested due to automatic review settings September 25, 2026 20:15

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.

Copilot review overview

🟡 Changes recommended

Unresolved MTP client lifecycle, cancellation, and integration-test issues block approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)

Comment on lines +183 to +186
private static async Task StopClientAsync(MtpServerClient client, CancellationToken cancellationToken)
{
await client.ExitAsync(cancellationToken).ConfigureAwait(false);
await client.ShutdownAsync().ConfigureAwait(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants