fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

how to make a static ctor in generative providers? #246

Closed giacomociti closed 6 years ago

giacomociti commented 6 years ago

I'm trying to add a static constructor in a generative type provider:

let addStaticCtor (providedType: ProvidedTypeDefinition) =
    let ctor = ProvidedConstructor([], invokeCode = fun _ -> <@@ printfn "hello" @@>)
    ctor.IsTypeInitializer <- true
    providedType.AddMember ctor

but the constructor is not generated. Is this the intended way to do it?

In previous versions, it was allowed to first specify the flag (IsTypeInitializer=true) and then setting the InvokeCode property, see for example this type provider.

What am I missing?

dsyme commented 6 years ago

Looks like missing functionality, will add it now

giacomociti commented 6 years ago

Thanks!