f# - Type Providers - Could I generate a type at compilation-time that decorates all methods of a type somehow? -


i've read great capabilities of type providers, such static-typing when querying json documents, can imagine can create have in mind @ moment, technology.

let's want allow consumer of typeprovider-library foo way create type bar, have following pre-condition each of methods: check mutable state of boolean disposed field, if it's true, throw objectdisposedexception.

would possible? how 1 define such implementation of high-level type creator?

a couple of years keith battocchi published project called ilbuilder. among other things ilbuilder contains method type provider in ilbuilder.fs provides methods types in mscorlib, e.g.

methodprovider.methods.system.console.``writeline : string*obj->unit` 

it possible use starting point type provider wraps classes assembly , provides methods.

another option might consider ross mckinlay's mixin type provider (ab)uses f#'s type provider mechanism provide meta-programming capabilities.

yet option might use postsharp, fody etc. il weaving, or code generation via reflection build proxy classes.

that said lowest friction solution create function checks disposal , manually add each member.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -