Skip to content
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

Support for pickling code from Reflection.Emit? #123

Open
hsenag opened this issue Jun 21, 2021 · 1 comment
Open

Support for pickling code from Reflection.Emit? #123

hsenag opened this issue Jun 21, 2021 · 1 comment

Comments

@hsenag
Copy link

hsenag commented Jun 21, 2021

Would it be plausible to add support to pickle things produced by System.Reflection.Emit, or is that inherently difficult?

My use case is that for slightly complicated reasons I want to send some code from machine A to B via a quotation, execute part of that code on B and then send a continuation to machine C via FSPickler.

A very simplified example would be

let v = <@ fun x -> x+1 @>

let w : int -> int = FSharp.Quotations.Evaluator.QuotationEvaluator.Evaluate v

let fspickler = MBrace.FsPickler.FsPickler.CreateBinarySerializer()
fspickler.Pickle(w)

which currently fails as expected because System.Reflection.Emit.DynamicMethod+RTDynamicMethod is not serializable by FsPickler:

 Unhandled exception. MBrace.FsPickler.FsPicklerException: Error serializing object of type 'Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,System.Int32]'.
---> MBrace.FsPickler.NonSerializableTypeException: Type 'System.Reflection.Emit.DynamicMethod+RTDynamicMethod' is not serializable: global method 'Int32 lambda_method(System.Runtime.CompilerServices.Closure, Microsoft.FSharp.Core.Unit, Int32)' in assembly 'Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

I'm aware of Vagabond but currently it only advertises support for .NET Core 3.1 and I also need to support .NET Framework 4. Would I be better off trying to get Vagabond to support .NET Standard?

@0x53A
Copy link
Contributor

0x53A commented Aug 31, 2021

I'm aware of Vagabond but currently it only advertises support for .NET Core 3.1 and I also need to support .NET Framework 4.

I randomly saw this, and just wanted to mention that this commit removed .NET FX support from Vagabond.

You might just be able to use an older version from NuGet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants