Skip to content

Instantly share code, notes, and snippets.

@hodzanassredin
Created September 18, 2011 09:44
Show Gist options
  • Save hodzanassredin/1224920 to your computer and use it in GitHub Desktop.
Save hodzanassredin/1224920 to your computer and use it in GitHub Desktop.
TypeProvider demo from @dsyme presentation
// Learn more about F# at http://fsharp.net
namespace ExampleTypeProvider.DesignTime
open System
open System.Collections.Generic
open System.Linq.Expressions
open System.Globalization
open System.Reflection
open System.Diagnostics
open Microsoft.FSharp.Core.CompilerServices
[<TypeProvider>]
type FolderTypeProvider(config:TypeProviderConfig) as this =
inherit TypeProviderForNamespaces()
let oneType = ProvidedTypeDefenition("Samples.TypeSpace", "OneType")
let prop = ProvidedProperty("Name", typeof<string>,
IsStatic = true,
GetterCode = (fun args-> <@@ "hello" @@>))
do oneType.AddMember prop
do this.AddNamespace("Samples.TypeSpace", [oneType])
[<assembly: TypeProviderAssembly>]
do()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment