Skip to content

Commit 5f958fb

Browse files
authored
FSI: make scripting temp directory one per session instead of global (#17760)
* make scripting temp per session * release notes
1 parent f564cc9 commit 5f958fb

File tree

2 files changed

+29
-29
lines changed
  • docs/release-notes/.FSharp.Compiler.Service
  • src/Compiler/Interactive

2 files changed

+29
-29
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.100.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
* Optimize ILTypeDef interface impls reading from metadata. ([PR #17382](https://github.com/dotnet/fsharp/pull/17382))
5555
* Make ILTypeDef interface impls calculation lazy. ([PR #17392](https://github.com/dotnet/fsharp/pull/17392))
5656
* Better error reporting for active patterns. ([PR #17666](https://github.com/dotnet/fsharp/pull/17666))
57+
* Multiple fsi sessions use separate temporary directories ([PR #17760](https://github.com/dotnet/fsharp/pull/17760))
5758

5859
### Breaking Changes

src/Compiler/Interactive/fsi.fs

+28-29
Original file line numberDiff line numberDiff line change
@@ -1675,34 +1675,6 @@ let internal mkBoundValueTypedImpl tcGlobals m moduleName name ty =
16751675
let qname = QualifiedNameOfFile.QualifiedNameOfFile(Ident(moduleName, m))
16761676
entity, v, CheckedImplFile.CheckedImplFile(qname, [], mty, contents, false, false, StampMap.Empty, Map.empty)
16771677

1678-
let scriptingSymbolsPath =
1679-
let createDirectory (path: string) =
1680-
lazy
1681-
try
1682-
if not (Directory.Exists(path)) then
1683-
Directory.CreateDirectory(path) |> ignore
1684-
1685-
path
1686-
with _ ->
1687-
path
1688-
1689-
createDirectory (Path.Combine(Path.GetTempPath(), $"{DateTime.Now:s}-{Guid.NewGuid():n}".Replace(':', '-')))
1690-
1691-
let deleteScriptingSymbols () =
1692-
try
1693-
#if !DEBUG
1694-
if scriptingSymbolsPath.IsValueCreated then
1695-
if Directory.Exists(scriptingSymbolsPath.Value) then
1696-
Directory.Delete(scriptingSymbolsPath.Value, true)
1697-
#else
1698-
()
1699-
#endif
1700-
with _ ->
1701-
()
1702-
1703-
AppDomain.CurrentDomain.ProcessExit
1704-
|> Event.add (fun _ -> deleteScriptingSymbols ())
1705-
17061678
let dynamicCcuName = "FSI-ASSEMBLY"
17071679

17081680
/// Encapsulates the coordination of the typechecking, optimization and code generation
@@ -1764,6 +1736,33 @@ type internal FsiDynamicCompiler
17641736

17651737
let reportedAssemblies = Dictionary<string, DateTime>()
17661738

1739+
let scriptingSymbolsPath =
1740+
let createDirectory (path: string) =
1741+
try
1742+
if not (Directory.Exists(path)) then
1743+
Directory.CreateDirectory(path) |> ignore
1744+
1745+
path
1746+
with _ ->
1747+
path
1748+
1749+
createDirectory (Path.Combine(Path.GetTempPath(), $"{DateTime.Now:s}-{Guid.NewGuid():n}".Replace(':', '-')))
1750+
1751+
let deleteScriptingSymbols () =
1752+
try
1753+
#if !DEBUG
1754+
if Directory.Exists(scriptingSymbolsPath) then
1755+
Directory.Delete(scriptingSymbolsPath, true)
1756+
#else
1757+
()
1758+
#endif
1759+
with _ ->
1760+
()
1761+
1762+
do
1763+
AppDomain.CurrentDomain.ProcessExit
1764+
|> Event.add (fun _ -> deleteScriptingSymbols ())
1765+
17671766
/// Add attributes
17681767
let CreateModuleFragment (tcConfigB: TcConfigBuilder, dynamicCcuName, codegenResults) =
17691768
if progress then
@@ -1841,7 +1840,7 @@ type internal FsiDynamicCompiler
18411840
{
18421841
ilg = tcGlobals.ilg
18431842
outfile = $"{multiAssemblyName}-{dynamicAssemblyId}.dll"
1844-
pdbfile = Some(Path.Combine(scriptingSymbolsPath.Value, $"{multiAssemblyName}-{dynamicAssemblyId}.pdb"))
1843+
pdbfile = Some(Path.Combine(scriptingSymbolsPath, $"{multiAssemblyName}-{dynamicAssemblyId}.pdb"))
18451844
emitTailcalls = tcConfig.emitTailcalls
18461845
deterministic = tcConfig.deterministic
18471846
portablePDB = true

0 commit comments

Comments
 (0)