I'm experimenting with integration of F# as scripting language and have an issue with FsiEvaluationSession.AddBoundVariable
method. Problem is that this method creates variable of actual type of object, but I need to create variable of interface that it implements. I can't find AddBoundVariable<T>(string, T)
or any other overload that would allow be do that.
// located in common assembly
type IFoo =
abstract Foo : unit -> unit
type FooImpl() =
interface IFoo with
member _.Foo () = ()
// located in host
session.AddBoundVariable ("foo", Foo())
session.EvalInteraction "foo.Foo()" // throws, `FooImpl` type doesn't have `Foo` method
session.EvalInteraction """
let foo : IFoo = foo
foo.Foo()
""" // throws, `IFoo` not found
Question is: how can I create variable of type that I want?