Closed chkeita closed 5 years ago
Is it possible to implement a ProvidedRecord with this approach?
Not with this alone
What else do i need to do to have my type behave like a real record ?
You would need to modify the F# compiler (particularly infos.fs
) to understand the compiled version of records as actual records.
I think i have a working version of the changes needed for intellisense to work properly. However i am getting an exception when accessing the field at runtime.
Attempt by method 'Program.testRecordType()' to access field 'Program+TestType.prop1@' failed.
it looks like the compiler is accessing the backing field prop1@ instead of the public property prop1
My guess is that i am missing a couple of attribute on the internal field that i generate in the type provider. Unfortunately, i can't reflect on the backing field of real record type to find out what are the expected attributes.
Any pointers for how to solve this issue ?
The backing fields were supposed internal instead of private
Attempting to implement a Provided record
I am trying to implement a providedRecord for a type provider i a working on. My approach was to decompile a normal record and try to implement the methods and attributes present in the decompiled class. I used the decompiled code of this record as a template
here is the definition of the ProvidedRecord and an example of instantiation in a test Type Provider. and here is an example of usage of that provider (reproduced here)
What else do i need to do to have my type behave like a real record ? Is it possible to implement a ProvidedRecord with this approach?