Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nuget Script Restores when doing them in parallel #1275

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ open FSharp.Compiler.Symbols
open Microsoft.Extensions.Caching.Memory
open System
open FsToolkit.ErrorHandling
open System.Threading



Expand All @@ -34,6 +35,10 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe

let entityCache = EntityCache()

// FCS can't seem to handle parallel project restores for script files
// https://github.com/ionide/ionide-vscode-fsharp/issues/2005
let scriptLocker = new SemaphoreSlim(1, 1)

// This is used to hold previous check results for autocompletion.
// We can't seem to rely on the checker for previous cached versions
let memoryCache () =
Expand Down Expand Up @@ -211,9 +216,16 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
}

member self.GetProjectOptionsFromScript(file: string<LocalPath>, source, tfm) =
match tfm with
| FSIRefs.TFM.NetFx -> self.GetNetFxScriptOptions(file, source)
| FSIRefs.TFM.NetCore -> self.GetNetCoreScriptOptions(file, source)
async {
try
do! scriptLocker.WaitAsync() |> Async.AwaitTask

match tfm with
| FSIRefs.TFM.NetFx -> return! self.GetNetFxScriptOptions(file, source)
| FSIRefs.TFM.NetCore -> return! self.GetNetCoreScriptOptions(file, source)
finally
scriptLocker.Release() |> ignore<int>
}


member __.ScriptTypecheckRequirementsChanged =
Expand Down
Loading