Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
namespace TypeProvidersGeeksMs
open System
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open Microsoft.FSharp.Quotations
type SampleTypeProvider(config: TypeProviderConfig) as x =
inherit TypeProviderForNamespaces()
let ns = "Geeks.SampleTypeProvider"
let asm = Assembly.GetExecutingAssembly()
let doASimpleType() =
let t = ProvidedTypeDefinition(asm,ns,"NombreDeLaClase",Some typeof<obj>)
t.IsErased <- false
//Propiedad estática
let staticProp = ProvidedProperty("StaticProperty",typeof<string>,IsStatic=true,GetterCode=
(fun args ->
<@@ "Hello Geeks!" @@>))
t.AddMember staticProp
//Un constructor
let ctor = ProvidedConstructor(parameters = [ ],
InvokeCode= (fun args ->
<@@ "The object data" :> obj @@>))
t.AddMember ctor
let prop = ProvidedProperty("InstanceProperty",typeof<string>,IsStatic=false,GetterCode=
(fun args ->
<@@ "Hello Geeks! Desde una propiedad de instancia" @@>))
t.AddMember prop
let types = [doASimpleType()]
do x.AddNamespace(ns,types)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.