Skip to content

Fix lscache loading issues - #86148

Merged
jasonmalinowski merged 3 commits into
dotnet:mainfrom
jasonmalinowski:fix-lscache-loading-issues
Oct 21, 2026
Merged

jasonmalinowski merged 3 commits into
dotnet:mainfrom
jasonmalinowski:fix-lscache-loading-issues

Conversation

@jasonmalinowski

@jasonmalinowski jasonmalinowski commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

This fixes two issues:

  1. lscache loads were not loading metadata references.
  2. lscache loads were not loading document folders, and worse off once the real load happened we wouldn't update the folders either.

This replaces #86126 and #86049, but takes an opportunity to create common testing patterns for both of them.

Fixes dotnet/vscode-csharp#9885
Fixes microsoft/vscode-dotnettools#3663

Microsoft Reviewers: Open in CodeFlow

@jasonmalinowski jasonmalinowski self-assigned this Oct 20, 2026
Copilot AI balanced review requested due to automatic review settings October 20, 2026 20:19
@jasonmalinowski
jasonmalinowski requested a review from a team as a code owner October 20, 2026 20:19
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟡 Changes recommended

Fallback loading can discard parser-derived references and fail to resolve project-relative analyzer paths.

2 open issues
What changed in this PR

Restores references and document folders during cached language-server project loading, with shared regression-test patterns.

Changes:

  • Loads structured metadata and analyzer references, preserving aliases and interop settings.
  • Restores cached document folders and updates changed folders after full loading.
  • Adds cache-loading and project-update regression tests.
File Description
src/​Workspaces/​MSBuild/​Core/​MSBuild/​MSBuildProjectLoader.Worker.cs Consumes structured references.
src/​Workspaces/​MSBuild/​Contracts/​ProjectFileInfo.cs Defines optional structured-reference collections.
src/​Workspaces/​MSBuild/​Contracts/​MetadataReferenceItem.cs Carries interop embedding settings.
src/​Workspaces/​MSBuild/​BuildHost/​MSBuild/​VisualBasic/​VisualBasicCommandLineArgumentReader.cs Stops emitting explicit reference arguments.
src/​Workspaces/​MSBuild/​BuildHost/​MSBuild/​ProjectFile/​ProjectInstanceReader.cs Supplies structured fallback references.
src/​Workspaces/​MSBuild/​BuildHost/​MSBuild/​ProjectFile/​Extensions.cs Reads interop reference metadata.
src/​Workspaces/​MSBuild/​BuildHost/​MSBuild/​ProjectFile/​CommandLineArgumentReader.cs Removes reference argument helpers.
src/​Workspaces/​MSBuild/​BuildHost/​MSBuild/​CSharp/​CSharpCommandLineArgumentReader.cs Stops emitting explicit reference arguments.
src/​Workspaces/​MSBuild/​BuildHost/​MSBuild/​Constants/​MetadataNames.cs Adds interop metadata name.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​HostWorkspace/​LoadedProject.Target.cs Applies references and reconciles document changes.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​HostWorkspace/​LoadedProject.cs Includes folders in document comparisons.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer/​HostWorkspace/​LanguageServerProjectSystem.cs Restores cached references and folders.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.UnitTests/​LoadedProjectTests.cs Tests reference application and document updates.
src/​LanguageServer/​Microsoft.CodeAnalysis.LanguageServer.UnitTests/​LanguageServerProjectCacheTests.cs Tests cached folders and reference properties.

Review effort: Balanced

@davidwengier davidwengier 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.

Much nicer than my attempt, though I can see copilot has commented about VB runtime references, which is exactly the rabbit hole I disappeared down, so I trust your authority to ignore that. I guess for the C# extension it doesn't matter anyway.

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.

🟡 Changes recommended

Cached loading drops command-line module references, leaving their types unavailable until the full project load completes.

3 open issues

Review effort: Balanced

jasonmalinowski and others added 3 commits October 20, 2026 16:49
When we were reading from an lscache, we didn't read in metadata
references correctly. We did read them in to the ProjectFileInfo's
MetadataReferences, but it turns out that collection was only
intended for languages that didn't have their references in the
command line -- it wasn't actually being used at all in the C#/VB case
when we applied the data in LoadedProject.

There are two ways we could fix this: we could either turn the loaded
data into command line switches, or we could just change the semantics
of ProjectFileInfo and just use the metadata references provided as
a replacement for the command line string if we have the list. The
latter avoids creating any bugs around command line string escaping,
and nicely reuses what we already have so we don't have surprises like
this again.

One small side effect of this is the MetadataReferenceItem now needs
to support all Roslyn concepts, so EmbedInteropTypes gets added as a
member.

Fixes microsoft/vscode-dotnettools#3663
Loading from lscache was not bringing along document folder, so this
computes the data. Also ensure we correctly update folders if/when they
change.

Fixes dotnet/vscode-csharp#9885

Co-authored-by: David Barbet <dabarbet@microsoft.com>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 23:49
@jasonmalinowski
jasonmalinowski force-pushed the fix-lscache-loading-issues branch from d5d0792 to 3f3fa46 Compare October 20, 2026 23:49

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.

🔵 Needs a closer look

Shared reference contracts and fallback behavior across both workspace loaders warrant maintainer validation beyond the cache-focused tests.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@jasonmalinowski
jasonmalinowski merged commit a7627a9 into dotnet:main Oct 21, 2026
23 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Oct 21, 2026
@akhera99 akhera99 modified the milestones: Next, 18.13 Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

5 participants