Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit dd9259a

Browse files
TIHannosami
authored andcommitted
Clearing cache of projects that are not in the current solution (dotnet#9124)
* Clearing cache of projects that are not in the current solution * Update LanguageService.fs * Using seq instead of list * Fixed build
1 parent 3069c31 commit dd9259a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

LanguageService/FSharpProjectOptionsManager.fs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type private FSharpProjectOptionsMessage =
8181
| ClearSingleFileOptionsCache of DocumentId
8282

8383
[<Sealed>]
84-
type private FSharpProjectOptionsReactor (_workspace: VisualStudioWorkspace, settings: EditorOptions, _serviceProvider, checkerProvider: FSharpCheckerProvider) =
84+
type private FSharpProjectOptionsReactor (workspace: Workspace, settings: EditorOptions, _serviceProvider, checkerProvider: FSharpCheckerProvider) =
8585
let cancellationTokenSource = new CancellationTokenSource()
8686

8787
// Hack to store command line options from HandleCommandLineChanges
@@ -208,6 +208,22 @@ type private FSharpProjectOptionsReactor (_workspace: VisualStudioWorkspace, set
208208
if Array.isEmpty projectOptions.SourceFiles then
209209
return None
210210
else
211+
// Clear any caches that need clearing and invalidate the project.
212+
let currentSolution = workspace.CurrentSolution
213+
let projectsToClearCache =
214+
cache
215+
|> Seq.filter (fun pair -> not (currentSolution.ContainsProject pair.Key))
216+
217+
if not (Seq.isEmpty projectsToClearCache) then
218+
projectsToClearCache
219+
|> Seq.iter (fun pair -> cache.Remove pair.Key |> ignore)
220+
let options =
221+
projectsToClearCache
222+
|> Seq.map (fun pair ->
223+
let _, _, projectOptions = pair.Value
224+
projectOptions)
225+
checkerProvider.Checker.ClearCache(options, userOpName = "tryComputeOptions")
226+
211227
checkerProvider.Checker.InvalidateConfiguration(projectOptions, startBackgroundCompileIfAlreadySeen = false, userOpName = "computeOptions")
212228

213229
let parsingOptions, _ = checkerProvider.Checker.GetParsingOptionsFromProjectOptions(projectOptions)

0 commit comments

Comments
 (0)