I would like to craft a simple record type based on fields provided.
That is :
let rectype = MakeRecordType(['fieldname1'; 'fieldname2'])
Going directly to type providers looks like heavy gunpower for such a simple task.
Are there any other way ?
update
I found the following question which look very similar
Creating F# record through reflection
Putting aside the usefulness of the end result, a snippet below achieves exactly what you asked for in the spirit of my other related answer:
A sketch implementation of
RecordTypeMakeraccepts an arbitraryRecord typedefinition containingtype nameand array offield namesaccompanied byfield type names. Then behind the curtain it assembles a piece of F# code defining the requested Record type, compiles this code viaCodeDom provider, loads container assembly and provides access to this newly created synthetic Record type via Reflection. A test snippetdemonstrates for a purely synthetic type
myTypethe proof of concept: