-
Notifications
You must be signed in to change notification settings - Fork 832
Uniquely name generated assemblies for each fsi session #18443
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
Conversation
❗ Release notes required
|
|
Open question is: does any tooling expect the generated assembly name to be exactly "FSI-ASSEMBLY"? Will it break anything? |
|
There's definitely code out there relying on it to some degree: https://github.com/search?q=%22FSI-ASSEMBLY%22&type=code I know that Ionide watcher is multi-emit aware and so just looks for assemblies that start with that name, but some kind of tooling surface to determine if an Assembly is an FSI dynamic assembly would sidestep all of these hacks. |
|
Yeah, current situation is that multi-emit assemblies are all named "FSI-ASSEMBLY" and differ by version number only. |
Unfortunately it seems |
|
This is a rabbit hole already, but somewhat related: |
|
Failed to run : https://github.com/dotnet/fsharp/actions/runs/14252016316 |
|
Can we imagine a scenario where this is a breaking change for users of fsharp scripts via FSharp.Compiler.Service.dll ? |
|
Yes, if a user creates a FsiEvaluationSession, disposes it, and then creates another, the name of the assembly will be FSI-ASSEMBLY2. |
|
Current situation is: Now I wonder if better fix wouldn't be to just never resolve by simple name, even in case of single dynamic assembly. |
|
Closing in favor of #18465 |
|
Reflection with the name "FSI-ASSEMBLY" is not any sort of contract, so if it breaks someone, they have the deep joy of fixing it. The prior multi-emit implementation created assemblies with distinct names for each submission, the current multi-emit creates them with distinct version numbers. The comment for the PR, is that it needs more testing, I do want to consider the behaviour of multiple sessions. multi-emit+ treats each subsequent session similarly to a submission, in as much as it changes the version number and carries on regardless. This is probably not what a developer expects, but I think it should be a separate issue. For developers wanting to access the current session, we should probably add something to the fsi object that gives access to it. Yet another separate issue. |
Does it mean the IVT mechanism do not isolate sessions, i.e. previous submissions are visible to every other newer submission, regardless of session? |
[<Fact>]
let ``Internals from one session visible in next session``() =
let args = [| "--multiemit+" |]
use sessionOne = new FSharpScript(additionalArgs=args)
sessionOne.Eval("""let x = 42""") |> ignore
use sessionTwo = new FSharpScript(additionalArgs=args)
let result = sessionTwo.Eval("""x""") |> getValue
printfn "Result: %A" result
Assert.Equal("42", string result.Value.ReflectionValue)The test says the answer to my question is no. Although I still don't understand how it works :) |
Fixes #18441
The idea is to make each
FsiEvaluationSessionproduce uniquely named assemblies.That way there is no possibility of confusion when different sessions resolve assemblies.
The first session creates an assembly named
FSI-ASSEMBLYto keep things reasonably backwards compatible.Subsequent sessions get names
FSI-ASSEMBLY2,FSI-ASSEMBLY3and so on.To discover the name associated with the current session you can call
Assembly.GetExecutingAssembly().FullNamefrom fsi.TODO: