Skip to content

[Draft][Do Not Merge] Migrate VS 18 Pylance integration to consolidated LSP protocol - #8673

Open
Stella Huang (StellaHuang95) wants to merge 6 commits into
microsoft:mainfrom
StellaHuang95:stellahuang-microsoft-unified-lsp-protocol-migration
Open

Stella Huang (StellaHuang95) wants to merge 6 commits into
microsoft:mainfrom
StellaHuang95:stellahuang-microsoft-unified-lsp-protocol-migration

Conversation

@StellaHuang95

@StellaHuang95 Stella Huang (StellaHuang95) commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrate the VS 18 Pylance integration to Microsoft.VisualStudio.LanguageServer.Protocol.Internal 18.14.12 and System.Text.Json in one main-based change.
  • Adapt generated message types, completion unions, member names, URI handling, configuration/workspace DTOs, custom RPC callbacks, REPL synchronization, and completion commit handling.
  • Align the required SDK dependencies, prefer desktop assets, and make reference selection deterministic when old package versions remain after an in-place restore.
  • Compile against the Internal package and bind at runtime to the copy Visual Studio ships. VS main redirects Internal 18.14.3–18.14.12 to its own 18.14.12, so PTVS packages neither the Internal DLL nor the legacy protocol DLL and registers no codebase for them.
  • Retain legacy-target protocol/serializer branches and Newtonsoft.Json in unrelated components.
  • Preserve existing file-watching, workspace, cancellation, handler-ordering, and stream compatibility implementations. Replacing workarounds with built-in VS support is out of scope.

Uses #8671 and #8672 as reference starting points, but is based directly on main rather than stacked on either draft. Neither draft is modified by this change.

Validation

At head a136f539b:

  • Full VS 18 Python\Product\dirs.proj rebuild: 0 errors, 0 warnings. Python\Tests\Core\PythonToolsTests.csproj build: 0 errors.
  • 24/24 selected regression tests passed: ProtocolJsonSerializationTests, LspDiffTextEditFactoryTests, LanguageServerSettingsTests, and PythonAnalysisOptionsTests.
  • Core VSIX payload: no Microsoft.VisualStudio.LanguageServer.Protocol*.dll and no Internal codebase in any pkgdef; Microsoft.PythonTools.dll references Internal 18.14.12.0. The entry list is otherwise identical to the previous payload.
  • Runtime on VS IntCanary 18.14.12419.381 (main), which ships Internal 18.14.12: PTVS loaded from the candidate extension, Internal resolved only to VS's own image, Pylance initialized, client/registerCapability callbacks succeeded, and diagnostics were published with no exceptions.

Earlier heads (no C# source has changed since 766f91eeb; later commits changed only packaging, codebase registration and restore configuration):

  • Expanded x64 Priority-0 core run: 105 passed, 2 failed, 3 skipped. Every migration-selected test passed; the two failures are unchanged prerequisites (Black range formatting and a stale missing interpreter path).
  • Complete Core assembly: 196 passed, 3 failed, 15 skipped, with the same unchanged prerequisite failures. VS-interpreter project 9 passed, 1 skipped, one reproducible Python 3.14 failure in unchanged requirements-detection code. Non-UI debugger project 38/38. Test adapter 69 passed/1 skipped. Profiling, Cookiecutter and Django failures or gaps are unchanged prerequisites.
  • Regression coverage includes actual PTVS client requests and server callbacks over System.Text.Json JsonRpc, completion resolution/data, references, commands, null/disposed responses, incremental edits, configuration/workspace folders, filesystem notifications, UTF-8 framing, stale diagnostics, and insertion/replacement edits.
  • Manual end-to-end run on IntCanary 18.14.12413.20, whose in-box Internal was 18.14.11, so that candidate packaged the DLL and registered a codebase (b0495063f). Passed: project creation and Pylance start; completion, resolve, auto-import and the brackets option; hover, Go To Definition, Find All References, highlight, rename and signature help; diagnostics; code actions; type checking modes; Add New Item and external file changes; Interactive Window execute, completion, Clear and Reset; Execute Project in Interactive; debugging; global default environment changes; Open Folder with PythonSettings.json search paths; and solution/folder switch, exit and restart.
  • On the updated VS, VS's own codebase entry for Internal 18.14.12 replaced the one PTVS registered, and the packaged copy was never loaded. c986ff44c therefore stops packaging it.

Outstanding gates

  • CI restore. PTVS-Build run 26324.2 failed the Secure Supply Chain Analysis because Build\nuget.config declared extra feeds; a136f539b restores the single msft_consumption source. CI restores that feed anonymously, and seven pins are not yet saved there (anonymous download returns 401 "not yet saved"): Internal 18.14.12, plus CoreUtility, Language.StandardClassification, Text.Data, Text.Logic, Text.UI and Text.UI.Wpf 18.14.8. A feed Collaborator must save them before CI can restore.
  • Manual end-to-end re-run with the no-DLL candidate on the updated VS.
  • Insertion target. Insert only into VS main builds that ship Internal 18.14.12 or later; VS cannot redirect PTVS's 18.14.12 reference to an older copy.
  • Not run because of harness limits: context-menu Go To Definition, Peek and Ctrl+Click.
  • Pre-existing on main and not caused by this PR (track separately): the initialize stream rewrite does not apply on current VS, so Pylance roots at the solution folder and never requests workspace/configuration; GetSettings(null) prefers the REPL context while an Interactive Window is open; VS pushes {"settings":{}} when settings files change; committing Pylance's help completion can replace $help in the REPL.
  • The pinned Pylance payload is 2026.2.1, while the installed baseline has 2026.4.1.
  • Verify operation without the legacy compatibility policy before approving its removal.
  • Older-target source branches are retained, but full VS 17 qualification is not claimed.

Use Protocol.Internal 18.14.12 and System.Text.Json throughout the VS 18 Pylance protocol path. Adapt generated unions and wire contracts, preserve existing compatibility workarounds and legacy-target branches, align SDK resolution and VSIX packaging, and cover the actual client/host RPC paths with regression tests.

Based on the migration starting points in microsoft#8671 and microsoft#8672; this is one independent change based on main, without either draft commit in its ancestry.

Co-authored-by: Kayle Hinkle <kaylehinkle@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@StellaHuang95
Stella Huang (StellaHuang95) marked this pull request as ready for review November 20, 2026 23:14
@StellaHuang95 Stella Huang (StellaHuang95) changed the title Migrate VS 18 Pylance integration to consolidated LSP protocol [Draft][Do Not Merge] Migrate VS 18 Pylance integration to consolidated LSP protocol Nov 20, 2026
@StellaHuang95

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@bschnurr

Bill Schnurr (bschnurr) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR.

<Reference Include="Microsoft.VisualStudio.LanguageServer.Protocol.Internal" Condition="'$(VSTarget)' == '18.0'">
<Private>True</Private>
<IncludeInVSIX>True</IncludeInVSIX>
</Reference>

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.

Warning · Non-blocking recommendation

Could you align the VSIX installation target and prerequisite with the earliest host containing the consolidated LSP client, or retain an older-host compatibility path? The Internal reference and JsonElement callbacks are selected for every VS 18 target, while the README requires a consolidated-client host. If the advertised range remains [18.0,19.0), please confirm activation, completion, and callbacks on the earliest admitted host or raise the minimum version.

@bschnurr

Bill Schnurr (bschnurr) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Reviewed commit: a136f539b520f4ee85d8ad5be6eafec6fd148f90

Result: 🔴 could-not-verify

Verification details

Verification: Automated verification is best effort. The PR author remains responsible for testing.

Summary: [unavailable] Container verification could not start and local execution was not authorized for this PR HEAD: C:\Program Files\RedHat\Podman\podman.EXE --connection pyrx-automation failed: stderr: Error: unable to start container "0b8133327e06aaae4d286ff351524fbf98057fc32f619305291ee7af2464a574": crun: open `memory.max` for writing: No such file or directory: OCI runtime attempted to invoke a command that was not found

Test runs: none recorded.

Visual Studio main now ships Microsoft.VisualStudio.LanguageServer.Protocol.Internal
18.14.12 and redirects 18.14.3-18.14.12 references to it. Its own codebase entry
replaces the one PTVS registered, so the DLL packaged in the PTVS VSIX was never
loaded. Compile against the package without packaging the DLL or registering a
codebase, matching how PTVS consumes the LSP client and System.Text.Json.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The PR build's auto-injected Secure Supply Chain Analysis rejects
Build/nuget.config when it declares more than one feed, which failed
PTVS-Build run 26324.2. Revert to the single msft_consumption source used
on main. Pinned versions that are not yet saved in msft_consumption must be
saved there by a feed Collaborator before CI can restore them.

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

Copy link
Copy Markdown

@bschnurr Bill Schnurr (bschnurr) left a comment

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.

Approved via Review Center.

@bschnurr Bill Schnurr (bschnurr) added the review-auto:approved Automated review: no blocking findings (approval posted). label Nov 23, 2026

@rchiodo Rich Chiodo (rchiodo) 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.

Approved via Review Center.

This branch has not been deployed

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

Labels

review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants