Idea: Add CE Builder for Json erased types (as they are not records and with is missing)
Would be pretty useful to have CE builders for erased type, e.g. JsonProvider provided types, as they are immutable and using the full constructor is annoying especially for big objects...
type MyProvidedType =
JsonProvider<"""{ "name" : "hello", "test" : { "nested" : true }} """>
instead of
let myJsonValue = new MyJsonProvider
.Root(name="test", new MyJsonProvider.Nester(false))
// quickly becomes cumbersome for big object hierarchies! try with a big json file
do..
let my_provided_ce = MyProvidedType.Builder()
let myJsonValue = // MyProvidedType.Root
my_provided_ce { // uses Sample as base for builder
name "test"
}
let myOtherValue = // MyProvidedType.Root
my_provided_ce { // uses Sample as base for builder
test {
nested false
}
}
@jkone27 would you be interested in submitting a PR with a proposed implementation?
i could give it a try but i have not much idea where to start 😆, i did this (see below) once to add "copy mutation" to JsonProvider erased type, but ofc it's quite hacky and messy...
https://github.com/jkone27/FSharp.Data.Mutator
so i thought a similar approach could make it easier to work with and maybe useful in general for other erased types too? will try to checkout the repo as a start 👍
In the topic of possibly extending Fsharp.Data, which one would be the easiest option between these as per implementation ? Pros/cons/possible
- Allow JsonValue setters in generated types making them mutable (is it possible with erased types?) trike passing allowMutableProperties in the constructor of the provider
- Somehow generate record types instead of current types, as they have already the with copy mutator construct built in… (not sure if it’s feasible)
- Adding the CEs as proposed in the current approach (would it be for all types in Helper.fs ???
as per option 3 (add a CEs for generated types), should it be done in Helper.fs around here?

or here but then i guess it becomes something more specific, like each provider needs to add the extra CE builder to constructor..

one way i could add an optional setter code, this wouldn't require the overcomplication of adding the CEs methods (with CustomOperationAttribute) maybe... could be done in JsonGenerator.fs
(https://gist.github.com/odytrice/313b2107f6ad52de12ae89f35941d4b2)