TransparentCompiler: scripts read #load'ed files through the global FileSystem, and DocumentSource.Custom gives new versions on every call
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with GetProjectSnapshotFromScript in src/Compiler/Service/service.fs, then the version logic in CreateFromDocumentSource in FSharpProjectSnapshot.fs and the None fallback in FSharpSource.fs. The issue asks maintainers to choose between several designs, so there is no single fix to make yet. Done means a decision on the API shape and a stable version scheme, with the TransparentCompiler caching and script #load behaviour covered by tests.
由索引模型根据 Issue 内容生成。
描述
FsAutoComplete installs a process-wide FileSystemAutoOpens.FileSystem shim so FCS reads the in-memory text of open files. We would like to stop doing that and give each checker its own view of the files (ionide/FsAutoComplete#1555). With the TransparentCompiler, project files already come from snapshots we build ourselves. Scripts are the part that still goes through the global file system, and the per-checker alternative, DocumentSource.Custom, does not work well there yet.
Links are to main at 409c7a62.
1. GetProjectSnapshotFromScript ignores the checker's document source
FSharpChecker.GetProjectSnapshotFromScript falls back to DocumentSource.FileSystem when no documentSource is passed, also when the checker was created with DocumentSource.Custom (service.fs#L533). The TransparentCompiler's GetProjectOptionsFromScript always passes DocumentSource.FileSystem (TransparentCompiler.fs#L2377). So the files a script #loads are read through the global file system (FSharpProjectSnapshot.fs#L81-L89).
2. A custom document source gives every file snapshot a new version
FSharpFileSnapshot.CreateFromDocumentSource uses DateTime.Now.Ticks as the version (FSharpProjectSnapshot.fs#L95). Each call creates new versions for files that did not change, so the TransparentCompiler caches miss. This happens for:
- the
#loaded files whenGetProjectSnapshotFromScriptis givenDocumentSource.Custom(TransparentCompiler.fs#L2483); - every
FSharpProjectOptionsbased call on a TransparentCompiler created withDocumentSource.Custom, throughFSharpProjectSnapshot.FromOptions(FSharpProjectSnapshot.fs#L715-L738).
3. None from a custom document source throws
When the function returns None, CreateFromDocumentSource fails with "Couldn't get source for file" (FSharpProjectSnapshot.fs#L104). The BackgroundCompiler reads the file from disk in that case (FSharpSource.fs#L69-L77). An editor only knows the text of its open files, so with the TransparentCompiler it has to read every other file itself.
Possible changes
- Use the checker's document source in
GetProjectSnapshotFromScriptwhen none is passed. - Let a custom source return a version with the text, or use a stable version, for example the last write time for files read from disk.
- Treat
Noneas "read from the file system", as the BackgroundCompiler does. - Or, for the snapshot API: let the caller create the snapshots of the
#loaded files (astring -> Async<FSharpFileSnapshot>callback), as it already does for project files.
documentSource on FSharpChecker.Create is marked experimental and "likely to be removed in the future" (service.fsi#L53). If that is still the plan, which way should an editor give the TransparentCompiler the text of open files that a script #loads?
- 主要语言
- F#
- 星标
- 4.3k
- 派生
- 884
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 73
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/fsharp 的其他 Issue
-
Needs-Triage
难度 1/5 1 小时以内 新手友好度 95/100
维护者通常 2 天内回复
-
Semantic classification cache for opened documents is never populated (written to the unopened-documents cache)可能已有人在做 @xperiandri 于 69 天前认领。 未关闭Needs-Triage
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 2 天内回复
-
Needs-Triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
Bug Needs-Triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
Needs-Triage
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 2 天内回复
相似的 Issue
-
from-agent
难度 2/5 1-3 小时 新手友好度 62/100
-
code quality wasm backend
难度 1/5 1 小时以内 新手友好度 84/100
nanyx-lang/nanyx#930 ·
维护者通常 1 天内回复
-
mlir
难度 2/5 1-3 小时 新手友好度 68/100
llvm/llvm-project#241891 · 1 条评论 ·
维护者通常 1 天内回复
-
arrays bug intrinsic llvm medium priority wrong result
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
`lower_throw!` treats any function whose name contains `jl_error` etc. as a throw (kernel becomes a trap / segfault)可能已有人在做 @sasmith-14 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
JuliaGPU/GPUCompiler.jl#1088 ·
维护者通常 1 天内回复