Skip to content

Line Numbers missing in Exceptions #13290

Description

@goswinr

When using F# Interactive via FSharp.Compiler.Service 41.0.4 on net48 Exceptions do not include line numbers.
Line numbers are only shown on net6.0 :
image

Is there a way to make exceptions include line numbers when on net48 ?
I am hosting fsi in a much larger net48 process. So I can't switch to net6.0.

code used:

let code = """
try
    8 / 0 |> ignore
with e -> 
    printfn $"Runtime: {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription}"
    printfn $"Error: {e}" 
"""

open System
open System.IO
open FSharp.Compiler.Interactive.Shell

let eval(codeStr) = 
    let inn = new StringReader("")
    let out = Console.Out
    let config = FsiEvaluationSession.GetDefaultConfiguration()
    let noArgs = [| "the first arg is neded, but ignored"|]
    let session = FsiEvaluationSession.Create(config, noArgs, inn, out, out)
    session.EvalInteraction(codeStr)

eval(code)
    
System.Console.ReadLine() |> ignore

and

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net48;net6.0</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Update="FSharp.Core" Version="6.0.4" />
    <PackageReference Include="FSharp.Compiler.Service" Version="41.0.4" />
  </ItemGroup>
</Project>

full repo: https://github.com/goswinr/ErrorLineNumberMissing

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions