fsprojects / FSharp.Formatting

F# tools for generating documentation (Markdown processor and F# code formatter)
https://fsprojects.github.io/FSharp.Formatting/
Other
464 stars 155 forks source link

Cannot use the evaluator from .net7 scripts #810

Open nhirschey opened 1 year ago

nhirschey commented 1 year ago

This seems to be an upstream, FSharp issue. See https://github.com/dotnet/fsharp/issues/14622#issuecomment-1466483603

This is the example from the FSharp.Formatting.Literate.Evaluation docs that used to work.

#r "nuget: FSharp.Formatting, 17.*"
open FSharp.Formatting.Literate
open FSharp.Formatting.Literate.Evaluation
open FSharp.Formatting.Markdown

// Sample literate content
let content =
    """
let a = 10
(*** include-value:a ***)"""

// Create evaluator and parse script
let fsi = FsiEvaluator()

let doc = Literate.ParseScriptString(content, fsiEvaluator = fsi)

Literate.ToHtml(doc)
> 
Error establishing FSI:
input.fsx (1,1)-(1,1) interactive error internal error: The thread is already executing the ControlledExecution.Run method.

Exception: FSharp.Compiler.Interactive.Shell+FsiCompilationException: Operation could not be completed due to earlier error
FSharp.Compiler.Interactive.Shell+FsiCompilationException: Operation could not be completed due to earlier error
   at FSharp.Formatting.Literate.Evaluation.FsiEvaluator..ctor(FSharpOption`1 options, FSharpOption`1 fsiObj, FSharpOption`1 addHtmlPrinter, FSharpOption`1 discardStdOut, FSharpOption`1 disableFsiObj, FSharpOption`1 onError) in /home/runner/work/FSharp.Formatting/FSharp.Formatting/src/FSharp.Formatting.Literate/Evaluator.fs:line 371
   at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\Users\nicho\Untitled-1:line 15
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error