From 254e036ac1a68053205d198859860d5e228c72f6 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Tue, 17 Sep 2024 18:52:14 +0200 Subject: [PATCH 1/2] make scripting temp per session --- src/Compiler/Interactive/fsi.fs | 57 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 832327656d9..10991bb59f7 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -1675,34 +1675,6 @@ let internal mkBoundValueTypedImpl tcGlobals m moduleName name ty = let qname = QualifiedNameOfFile.QualifiedNameOfFile(Ident(moduleName, m)) entity, v, CheckedImplFile.CheckedImplFile(qname, [], mty, contents, false, false, StampMap.Empty, Map.empty) -let scriptingSymbolsPath = - let createDirectory (path: string) = - lazy - try - if not (Directory.Exists(path)) then - Directory.CreateDirectory(path) |> ignore - - path - with _ -> - path - - createDirectory (Path.Combine(Path.GetTempPath(), $"{DateTime.Now:s}-{Guid.NewGuid():n}".Replace(':', '-'))) - -let deleteScriptingSymbols () = - try -#if !DEBUG - if scriptingSymbolsPath.IsValueCreated then - if Directory.Exists(scriptingSymbolsPath.Value) then - Directory.Delete(scriptingSymbolsPath.Value, true) -#else - () -#endif - with _ -> - () - -AppDomain.CurrentDomain.ProcessExit -|> Event.add (fun _ -> deleteScriptingSymbols ()) - let dynamicCcuName = "FSI-ASSEMBLY" /// Encapsulates the coordination of the typechecking, optimization and code generation @@ -1764,6 +1736,33 @@ type internal FsiDynamicCompiler let reportedAssemblies = Dictionary() + let scriptingSymbolsPath = + let createDirectory (path: string) = + try + if not (Directory.Exists(path)) then + Directory.CreateDirectory(path) |> ignore + + path + with _ -> + path + + createDirectory (Path.Combine(Path.GetTempPath(), $"{DateTime.Now:s}-{Guid.NewGuid():n}".Replace(':', '-'))) + + let deleteScriptingSymbols () = + try +#if !DEBUG + if Directory.Exists(scriptingSymbolsPath) then + Directory.Delete(scriptingSymbolsPath, true) +#else + () +#endif + with _ -> + () + + do + AppDomain.CurrentDomain.ProcessExit + |> Event.add (fun _ -> deleteScriptingSymbols ()) + /// Add attributes let CreateModuleFragment (tcConfigB: TcConfigBuilder, dynamicCcuName, codegenResults) = if progress then @@ -1841,7 +1840,7 @@ type internal FsiDynamicCompiler { ilg = tcGlobals.ilg outfile = $"{multiAssemblyName}-{dynamicAssemblyId}.dll" - pdbfile = Some(Path.Combine(scriptingSymbolsPath.Value, $"{multiAssemblyName}-{dynamicAssemblyId}.pdb")) + pdbfile = Some(Path.Combine(scriptingSymbolsPath, $"{multiAssemblyName}-{dynamicAssemblyId}.pdb")) emitTailcalls = tcConfig.emitTailcalls deterministic = tcConfig.deterministic portablePDB = true From cd54fc2d43d97e8c4894473a45f0b7a250e4cdf4 Mon Sep 17 00:00:00 2001 From: Jakub Majocha <1760221+majocha@users.noreply.github.com> Date: Tue, 17 Sep 2024 19:07:06 +0200 Subject: [PATCH 2/2] release notes --- docs/release-notes/.FSharp.Compiler.Service/9.0.100.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md index 91b91f3c3eb..1b4adfe0c9f 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md @@ -53,6 +53,7 @@ * Better error reporting for let bindings. ([PR #17601](https://github.com/dotnet/fsharp/pull/17601)) * Optimize ILTypeDef interface impls reading from metadata. ([PR #17382](https://github.com/dotnet/fsharp/pull/17382)) * Better error reporting for active patterns. ([PR #17666](https://github.com/dotnet/fsharp/pull/17666)) +* Multiple fsi sessions use separate temporary directories ([PR #17760](https://github.com/dotnet/fsharp/pull/17760)) ### Breaking Changes