0

I try to call JsonConverter<'t>.Read using reflection

static member ConvertRead (readInfo: MethodInfo, converter: JsonConverter, reader: byref<Utf8JsonReader>, typeToConvert: Type, options: JsonSerializerOptions) =
    readInfo.Invoke(converter, [| box reader; box typeToConvert; box options |])

and get FS0412: A type instantiation involves a byref type. This is not permitted by the rules of Common IL

dbc
  • 104,963
  • 20
  • 228
  • 340
Andrii
  • 1,081
  • 1
  • 11
  • 24
  • Looks like answer to the c# question [How to pass an argument by reference using Reflection](https://stackoverflow.com/q/60830084) does what you want -- specifically using `Utf8JsonReader` as an example. Is that enough to answer your question? Do you need help converting it to f#? – dbc Feb 02 '23 at 23:32
  • Yes I do need help – Andrii Feb 10 '23 at 00:00
  • OK, can you show a little more of your current code then? Specifically how you created `readInfo`, whether you are inside some generic class or method with `'t` as a type parameter, and so on. I.e. a [mcve] showing where you're stuck. Thanks! – dbc Feb 10 '23 at 00:06

0 Answers0