Repository navigation
Conversation
When the Transparent Compiler checks a single file, it type checks every file before it, even files the checked file does not depend on. Tools that only need the typed tree of one file, such as signature generators and analyzers, pay for the whole project. The snapshot overload of FSharpChecker.ParseAndCheckFileInProject takes a new optional ?checkDependenciesOnly. When set, the dependency graph is trimmed with Graph.subGraphFor to the checked file and its transitive dependencies. The typed tree of the file is the same as with a full check. The partial assembly signature and DependencyFiles only cover the file and its dependencies, so these results bypass the ParseAndCheckFileInProject cache and are never served to later full requests. The BackgroundCompiler ignores the flag. The full check stays the default. subGraphFor now uses a HashSet lookup instead of Array.contains. Re-enables the assertion in "We don't check files that are not depended on" and adds tests for signature parity, diagnostics parity, signature files, and the cache bypass. dotnet#20850
Contributor
✅ Release notes checked
|
nojaf
marked this pull request as ready for review
October 30, 2026 12:28
T-Gro
self-requested a review
November 2, 2026 12:32
The conflict resolution in merge 54ec285 took main's signature and dropped the parameter, while the body and callers still use it, so TransparentCompiler.fs no longer compiled.
This branch has not been deployed
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.
Description
Fixes #20850
When the Transparent Compiler checks a single file, it type checks every file before it, including files the checked file does not depend on. Tools that only need the typed tree of one file (Telplin generating a signature for one file, analyzers, code generators) pay for the whole project.
The snapshot overload of
FSharpChecker.ParseAndCheckFileInProjecttakes a new optional?checkDependenciesOnly. When it is set, the file's dependency graph is trimmed withGraph.subGraphFor, the line that was commented out inComputeDependencyGraphForFile, so only the checked file and its transitive dependencies are type checked. The full check stays the default, and theBackgroundCompilerignores the flag.What a caller gets:
tcEnvand the checked file's own diagnostics are the same as with a full check. Even in a full check, each file is checked against the state of its graph dependencies only, so the subgraph only skips the files that were never needed.DependencyFilesonly cover the file and its dependencies.ParseAndCheckFileInProjectcache, so a later fullParseAndCheckFileInProject,TryGetRecentCheckResultsForFileorGetCachedCheckFileResultnever gets them. The per-fileTcIntermediatecache is shared between both modes, which is safe because every file in the subgraph starts from the same input state in both.subGraphFornow uses aHashSetinstead ofArray.contains.Measurement
A synthetic project of 30 independent files (750 declarations each), plus a
Last.fsthat uses onlyF01. A new checker for each check, Release build:F02.fs, all prior filesLast.fs, all prior filesLast.fs, dependencies onlyTests
We don't check files that are not depended onnow uses the new mode, and its commented-out assertion (check "FileSecond.fs" []) is enabled..fsi, and a checked file with its own.fsi.TryGetRecentCheckResultsForFile.Graph.subGraphFor.Not in this PR
The skipped
Files that are not depended on don't invalidate cachetests still fail.TcIntermediateis keyed on all prior files (FileKey(index)), so editing an unrelated earlier file still invalidates the checked file. Keying it on the file's dependencies is what the original design did, and it was removed when signature-file support went in (0101@0a35243). That is a separate change.Question for maintainers
Was there a reason, beyond the missing "complete vs minimal" request type, that the subgraph was disabled in that commit?
Checklist