Skip to content

FSharpProjectSnapshot: use arrays instead of lists for source files and referenced projects - #20875

Open
DedSec256 wants to merge 3 commits into
dotnet:mainfrom
DedSec256:ber.a/projectSnapshotArrays
Open

DedSec256 wants to merge 3 commits into
dotnet:mainfrom
DedSec256:ber.a/projectSnapshotArrays

Conversation

@DedSec256

Copy link
Copy Markdown
Contributor

ProjectSnapshotBase stored its source files and referenced projects as lists. The TransparentCompiler usually needs them as arrays, so the code kept converting back and forth:

  • Every producer of a snapshot stage (LoadSources, parseSourceFiles, parseSourceFilesExceptImplFilesWithSignatures, FromOptions, GetProjectSnapshotFromScript) gets an array from MultipleDiagnosticsLoggers.Parallel and turned it into a list with Array.toList. parseSourceFilesExceptImplFilesWithSignatures then turned it back with List.toArray.
  • ComputeTcIntermediate and the ArtificialImplFile branch of processGraphNode read the file by index, projectSnapshot.SourceFiles[index]. On a list each read walks the list, which makes type checking a project quadratic in its file count.
  • List.last, .Length and List.tryItem are used in several places.

This PR makes sourceFiles and referencedProjects arrays.

Breaking change (experimental API)

The public surface of FSharpProjectSnapshot changes:

  • SourceFiles: FSharpFileSnapshot[]
  • ReferencedProjects: FSharpReferencedProjectSnapshot[]
  • Create(..., sourceFiles: FSharpFileSnapshot[], ..., referencedProjects: FSharpReferencedProjectSnapshot[], ...)
  • Replace(changedSourceFiles: FSharpFileSnapshot[])

The API is marked [<Experimental>]. Callers have to pass and consume arrays instead of lists. The surface area baseline is updated.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release notes checked


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.200.md
`vsintegration/src` docs/release-notes/.VisualStudio/18.vNext.md

@DedSec256
DedSec256 marked this pull request as ready for review October 27, 2026 18:47
@DedSec256
DedSec256 requested a review from a team as a code owner October 27, 2026 18:47

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

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant