Skip to content

Commit

Permalink
only allow one GetProjectOptionsFromScript at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Apr 25, 2024
1 parent ab6a49d commit d435c11
Showing 1 changed file with 15 additions and 3 deletions.
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

0 comments on commit d435c11

Please sign in to comment.