protobuf-net-fsharp icon indicating copy to clipboard operation
protobuf-net-fsharp copied to clipboard

Consider alternative or refactor to Reflection.Emit code

Open mvkara opened this issue 4 years ago • 2 comments

Given protobuf-net's main way to customise things is via surrogates some type generation is probably necessary going forward. However recent reliance on the API IMO makes the API less maintainable and brittle to any changes coming in.

Consider things like using the Type Provider SDK, quotations, etc particularly around the op_Implicit and op_Explicit methods to make the logic more customizable, and help support other future cases.

mvkara avatar Aug 30 '21 03:08 mvkara

If I remember correctly (also my knowledge is from ~1.5 years ago and may be outdated), Type Provider SDK generates types in compile-time only and is not that easy to use too.

mishun avatar Aug 30 '21 03:08 mishun

Its been some time since I've done anything with the SDK to be honest as well so my knowledge is outdated too - it used to do Reflection.Emit but I think with NET Core they may of moved to another method.

Even still this ticket is a placeholder to find a better way to generate the type data required here. Quotations that even use the basic quotations compiler built into FSharp.Core (Microsoft.FSharp.Linq.RuntimeHelpers) or one of the more recent quotation libraries would be fine even if we take an additional dependency. Shrinking the code in CodeGen.fs would be the focus.

This ticket really is a placeholder to investigate this at some point and come up with an alternative maintainable option that is not as error prone, and allows us to develop more support rapidly.

mvkara avatar Aug 30 '21 05:08 mvkara