Skip to content

Opening namespace/module after referencing nuget package doesn't work on a kernel extension #1307

@PawelStadnicki

Description

@PawelStadnicki

I have F# kernel extension in which (among other requirements) I want to reference nuget packages (to avoid doing it in the editor and disturbing users from proper value) AND open namespaces.

My OnLoadAsync method contains following code piece :

let code = 
    [
        "#r nuget:Feliz"
        "open Feliz"
    ] |> String.concat Environment.NewLine
    
    kernel.VisitSubkernelsAndSelf(
        function
        | :? FSharpKernel as fs  -> 

            fs.SendAsync(SubmitCode (code,"fsharp")) 
                        |> Async.AwaitTask 
                        |> Async.RunSynchronously
        | _ -> ()
    )

Package loads successfully but it fails upon opening namespaces/modules:

Error: input.fsx (2,6)-(2,11) typecheck error The namespace or module 'Feliz' is not defined.

Exactly the same code inserted into cell works fine:

r# nuget:Feliz
open Feliz

Is this kernel extension limitation/ by design ? I suspect rather that it is more kernel context operation involved that I may use in a wrong way

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Packages and ExtensionsRelated to acquiring and using packages and extensionsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions