Skip to content

Build a project's TcGlobals with its own path map when the framework imports are cached - #20476

Open
xperiandri wants to merge 3 commits into
dotnet:mainfrom
xperiandri:fix/framework-cache-pathmap
Open

xperiandri wants to merge 3 commits into
dotnet:mainfrom
xperiandri:fix/framework-cache-pathmap

Conversation

@xperiandri

@xperiandri xperiandri commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #20474

FrameworkImportsCache caches the framework TcImports together with the TcGlobals built for the first project of a framework set, and its key does not include the path map. A project reusing the entry got a new TcGlobals only when langVersion or realsig differed, and copied pathMap from the cached instance even then. TypedTreePickle.p_range applies that map to every range it writes and EncodeSignatureData to compileTimeWorkingDir, so the in-memory reference data a project exposes to its consumers was mapped with the --pathmap of whichever project filled the cache first: a project without a map lent mapped, relative file names to its consumers, and a project with a map lost it when a sibling came first.

Seen in Visual Studio on a solution with <PathMap> in Directory.Build.props: symbols imported from a sibling project carried a doubled, relative file name and Go To Definition opened the generated signature.

pathMap now takes part in the decision to rebuild TcGlobals, like langVersion and realsig, and the new instance takes it from the project's own TcConfig. The cached framework imports do not depend on the map, so the key is unchanged.

#20470 keeps the IDE from passing --pathmap at all; this makes the cache correct for any host that checks mapped and unmapped projects with one FSharpChecker.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev

@xperiandri,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

`* . (PR #XXXXX)`

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.200.md No release notes found or release notes format is not correct

xperiandri added a commit to xperiandri/fsharp that referenced this pull request Sep 7, 2026
@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Sep 7, 2026
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Sep 7, 2026
@xperiandri
xperiandri force-pushed the fix/framework-cache-pathmap branch from 54a06cf to 0c4b74a Compare September 7, 2026 12:52

@T-Gro T-Gro 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; CI is still running.

@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Sep 7, 2026
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Sep 11, 2026
xperiandri added a commit to xperiandri/fsharp that referenced this pull request Sep 11, 2026
@xperiandri
xperiandri force-pushed the fix/framework-cache-pathmap branch from 0c4b74a to 93a30a9 Compare September 11, 2026 16:17
@github-actions github-actions Bot added the ⚠️ Affects-Design-Time Tooling check: PR touches type providers or dependency manager label Sep 11, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@T-Gro T-Gro 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.

🤖🕵️ Please make the description more concise using this guidance. Keep the problem and why the change is needed prominent, using short sentences in simplified technical English. Retain necessary caveats.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Tooling Safety Check — Affects-Design-Time
Affects-Design-Time: Compiler service or Visual Studio behavior changed.

Generated by PR Tooling Safety Check · gpt56 1.9M · ◷

xperiandri added a commit to xperiandri/fsharp that referenced this pull request Sep 26, 2026
xperiandri and others added 3 commits September 26, 2026 03:00
…imports are cached

FrameworkImportsCache keys the framework imports, and the TcGlobals built
with them, by the framework set alone. A project reusing the entry got a
fresh TcGlobals only when langVersion or realsig differed, and even then took
pathMap from the cached instance. Since TypedTreePickle applies that map to
every range it writes, the in-memory reference data of each project carried
the --pathmap of whichever project filled the cache first, and a project
without a map handed its consumers file names nothing on disk matches.

pathMap now takes part in the decision like langVersion and realsig, and the
new TcGlobals takes it from the project's own TcConfig, in the incremental
builder and the transparent compiler alike.

Fixes dotnet#20474

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ing project

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 26, 2026 01:00
@xperiandri
xperiandri force-pushed the fix/framework-cache-pathmap branch from 93a30a9 to ec062bd Compare September 26, 2026 01:00

Copilot AI left a comment

Copy link
Copy Markdown

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

Add coverage for a mapped project after an unmapped sibling populates the cache.

Review effort: Lite
Findings: None

What changed in this PR

Fixes framework import cache reuse so each project’s TcGlobals retains its own path map.

Changes:

  • Rebuilds TcGlobals when pathMap differs.
  • Applies project-specific path maps in both compiler paths.
  • Adds regression coverage and release notes.
File Summary
tests/​FSharp.Compiler.ComponentTests/​FSharpChecker/​PathMap.fs Adds path-map cache regression tests.
tests/​FSharp.Compiler.ComponentTests/​FSharp.Compiler.ComponentTests.fsproj Includes the new test file.
src/​Compiler/​Service/​TransparentCompiler.fs Applies project-specific path maps.
src/​Compiler/​Service/​IncrementalBuild.fs Handles path-map differences in cached globals.
docs/​release-notes/​.FSharp.Compiler.Service/​11.0.100.md Documents the fix.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

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

⚠️ Affects-Design-Time Tooling check: PR touches type providers or dependency manager AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

FrameworkImportsCache lends the first project's --pathmap to every project of the framework set

3 participants