From ba78ba30f20c7ac13cc950935055fb48d742e667 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 21 Oct 2016 19:32:44 +0100 Subject: [PATCH 1/3] Fix 631 --- src/fsharp/vs/service.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 50bfa1fa57..89be3ec607 100755 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -2718,7 +2718,7 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke let backgroundCompiler = BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) - static let globalInstance = FSharpChecker.Create() + static let globalInstance = lazy FSharpChecker.Create() // Parse using backgroundCompiler let ComputeBraceMatching(filename:string,source,options:FSharpProjectOptions) = @@ -2989,7 +2989,7 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke bc.ParseFileInProject(filename, source, options) |> Async.RunSynchronously - static member Instance = globalInstance + static member Instance = globalInstance.Value member internal __.FrameworkImportsCache = backgroundCompiler.FrameworkImportsCache From f09e4aa9415553b9e9ff2711b7a3a71dfa6b3e6e Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 21 Oct 2016 19:35:26 +0100 Subject: [PATCH 2/3] Fix 631 --- src/fsharp/fsi/fsi.fs | 17 +++++++---------- src/fsharp/fsi/fsi.fsi | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index ddeae1ff2f..beea9d53df 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -1513,14 +1513,11 @@ module internal MagicAssemblyResolution = let Install(tcConfigB, tcImports: TcImports, fsiDynamicCompiler: FsiDynamicCompiler, fsiConsoleOutput: FsiConsoleOutput) = - let rangeStdin = rangeN Lexhelp.stdinMockFilename 0 - #if TODO_REWORK_ASSEMBLY_LOAD ignore tcConfigB ignore tcImports ignore fsiDynamicCompiler ignore fsiConsoleOutput - ignore rangeStdin { new System.IDisposable with member x.Dispose() = () } #else @@ -2317,7 +2314,7 @@ let internal DriveFsiEventLoop (fsi: FsiEvaluationSessionHostConfig, fsiConsoleO /// The primary type, representing a full F# Interactive session, reading from the given /// text input, writing to the given text output and error writers. -type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], inReader:TextReader, outWriter:TextWriter, errorWriter: TextWriter, fsiCollectible: bool, msbuildEnabled: bool) = +type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], inReader:TextReader, outWriter:TextWriter, errorWriter: TextWriter, fsiCollectible: bool, msbuildEnabled: bool, checker: FSharpChecker) = #if DYNAMIC_CODE_REWRITES_CONSOLE_WRITE do Microsoft.FSharp.Core.Printf.setWriter outWriter @@ -2457,10 +2454,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i let fsiConsoleInput = FsiConsoleInput(fsi, fsiOptions, inReader, outWriter) - /// The single, global interactive checker that can be safely used in conjunction with other operations - /// on the FsiEvaluationSession. - let checker = FSharpChecker.Create() - let (tcGlobals,frameworkTcImports,nonFrameworkResolutions,unresolvedReferences) = try let tcConfig = tcConfigP.Get() @@ -2721,8 +2714,12 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i GC.KeepAlive fsiInterruptController.EventHandlers - static member Create(fsiConfig, argv, inReader, outWriter, errorWriter, ?collectible, ?msbuildEnabled) = - new FsiEvaluationSession(fsiConfig, argv, inReader, outWriter, errorWriter, defaultArg collectible false, defaultArg msbuildEnabled true) + static member Create(fsiConfig, argv, inReader, outWriter, errorWriter, ?collectible, ?msbuildEnabled, ?checker) = + /// The single, global interactive checker that can be safely used in conjunction with other operations + /// on the FsiEvaluationSession. + let checker = match checker with None -> FSharpChecker.Create() | Some c -> c + + new FsiEvaluationSession(fsiConfig, argv, inReader, outWriter, errorWriter, defaultArg collectible false, defaultArg msbuildEnabled true, checker) static member GetDefaultConfiguration(fsiObj:obj) = FsiEvaluationSession.GetDefaultConfiguration(fsiObj, true) diff --git a/src/fsharp/fsi/fsi.fsi b/src/fsharp/fsi/fsi.fsi index 6c9c343486..c20bfa31f2 100644 --- a/src/fsharp/fsi/fsi.fsi +++ b/src/fsharp/fsi/fsi.fsi @@ -124,7 +124,7 @@ type FsiEvaluationSession = /// Read input from the given reader /// Write output to the given writer /// Optionally make the dynamic assmbly for the session collectible - static member Create : fsiConfig: FsiEvaluationSessionHostConfig * argv:string[] * inReader:TextReader * outWriter:TextWriter * errorWriter: TextWriter * ?collectible: bool * ?msbuildEnabled: bool -> FsiEvaluationSession + static member Create : fsiConfig: FsiEvaluationSessionHostConfig * argv:string[] * inReader:TextReader * outWriter:TextWriter * errorWriter: TextWriter * ?collectible: bool * ?msbuildEnabled: bool * ?checker: FSharpChecker -> FsiEvaluationSession /// A host calls this to request an interrupt on the evaluation thread. member Interrupt : unit -> unit From 4f78d3b54b0cf285bcbef771617a5d97fd873893 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Fri, 21 Oct 2016 19:37:16 +0100 Subject: [PATCH 3/3] Fix 631 --- src/fsharp/fsi/fsi.fs | 14 +++++++------- src/fsharp/fsi/fsi.fsi | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index beea9d53df..f21e98be9f 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -2314,7 +2314,7 @@ let internal DriveFsiEventLoop (fsi: FsiEvaluationSessionHostConfig, fsiConsoleO /// The primary type, representing a full F# Interactive session, reading from the given /// text input, writing to the given text output and error writers. -type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], inReader:TextReader, outWriter:TextWriter, errorWriter: TextWriter, fsiCollectible: bool, msbuildEnabled: bool, checker: FSharpChecker) = +type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], inReader:TextReader, outWriter:TextWriter, errorWriter: TextWriter, fsiCollectible: bool, msbuildEnabled: bool) = #if DYNAMIC_CODE_REWRITES_CONSOLE_WRITE do Microsoft.FSharp.Core.Printf.setWriter outWriter @@ -2454,6 +2454,10 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i let fsiConsoleInput = FsiConsoleInput(fsi, fsiOptions, inReader, outWriter) + /// The single, global interactive checker that can be safely used in conjunction with other operations + /// on the FsiEvaluationSession. + let checker = FSharpChecker.Create(msbuildEnabled=msbuildEnabled) + let (tcGlobals,frameworkTcImports,nonFrameworkResolutions,unresolvedReferences) = try let tcConfig = tcConfigP.Get() @@ -2714,12 +2718,8 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i GC.KeepAlive fsiInterruptController.EventHandlers - static member Create(fsiConfig, argv, inReader, outWriter, errorWriter, ?collectible, ?msbuildEnabled, ?checker) = - /// The single, global interactive checker that can be safely used in conjunction with other operations - /// on the FsiEvaluationSession. - let checker = match checker with None -> FSharpChecker.Create() | Some c -> c - - new FsiEvaluationSession(fsiConfig, argv, inReader, outWriter, errorWriter, defaultArg collectible false, defaultArg msbuildEnabled true, checker) + static member Create(fsiConfig, argv, inReader, outWriter, errorWriter, ?collectible, ?msbuildEnabled) = + new FsiEvaluationSession(fsiConfig, argv, inReader, outWriter, errorWriter, defaultArg collectible false, defaultArg msbuildEnabled true) static member GetDefaultConfiguration(fsiObj:obj) = FsiEvaluationSession.GetDefaultConfiguration(fsiObj, true) diff --git a/src/fsharp/fsi/fsi.fsi b/src/fsharp/fsi/fsi.fsi index c20bfa31f2..6c9c343486 100644 --- a/src/fsharp/fsi/fsi.fsi +++ b/src/fsharp/fsi/fsi.fsi @@ -124,7 +124,7 @@ type FsiEvaluationSession = /// Read input from the given reader /// Write output to the given writer /// Optionally make the dynamic assmbly for the session collectible - static member Create : fsiConfig: FsiEvaluationSessionHostConfig * argv:string[] * inReader:TextReader * outWriter:TextWriter * errorWriter: TextWriter * ?collectible: bool * ?msbuildEnabled: bool * ?checker: FSharpChecker -> FsiEvaluationSession + static member Create : fsiConfig: FsiEvaluationSessionHostConfig * argv:string[] * inReader:TextReader * outWriter:TextWriter * errorWriter: TextWriter * ?collectible: bool * ?msbuildEnabled: bool -> FsiEvaluationSession /// A host calls this to request an interrupt on the evaluation thread. member Interrupt : unit -> unit