Partas.Feliz.Generator
                              
                            
                                0.7.0
                            
                        
                    dotnet add package Partas.Feliz.Generator --version 0.7.0
NuGet\Install-Package Partas.Feliz.Generator -Version 0.7.0
<PackageReference Include="Partas.Feliz.Generator" Version="0.7.0" />
<PackageVersion Include="Partas.Feliz.Generator" Version="0.7.0" />
<PackageReference Include="Partas.Feliz.Generator" />
paket add Partas.Feliz.Generator --version 0.7.0
#r "nuget: Partas.Feliz.Generator, 0.7.0"
#:package Partas.Feliz.Generator@0.7.0
#addin nuget:?package=Partas.Feliz.Generator&version=0.7.0
#tool nuget:?package=Partas.Feliz.Generator&version=0.7.0
Partas.Feliz.Generator
This is heavily WIP and currently not suitable for public use outside of contribution/testing
A simple  cool stupid generator using Fantomas and a previous script I made for refining Glultinum bindings.
Allows us to use a fsx script as a source of truth, with a simplified scheme of defining Feliz bindings, and then generating the file from that.
Goals
Maximize lazy cat vibes.
The 'DSL' is simply supposed to require less effort than manually creating the bindings. It can also be used as an intermediary for formats like yaml, or others.
Current API
API is constantly changing, check the tests to see what does what until I settle on something
// The definition of a file is done by building a schema
type Schema = {
    // Manipulate how things are generated
    Config: Config
    // The namespace for the file
    Namespace: string option
    // The modules to open at the head of the file
    RequiredOpens: string list
    // Our definitions for feliz style
    Interfaces: InterfaceType list
}
Interfaces are created by using the makeType utility in combination with the type name and a list of attribute definitions
let interfaces: InterfaceType list = [
    makeType "ParamOptions" [
        // attributes go here
    ]
]
Attributes are easily made using the =>> for properties with only one accepted type, and ==> to pass a list of accepted types
makeType "ParamOptions" [
    "testAttribute" =>> nameof float //same as "float"
    "testListAttr" ==> [
        nameof float
        nameof int
        nameof string
    ]
]
The real help here is the definition of enums using feliz style. Simply add a sublist of the string enum options
makeType "ParamOptions" [
                    // enums
    "testEnum" ==> [[ "center"; "right" ]]
    "testMix" ==> [
        // Special constant that is equivalent to
        // yield! [ nameof float; nameof int ]
        number
        // Special constant that is equivalent to
        // yield! [ "float array"; "int array" ]
        numberArray
        [ // enums
            "center"
            "right"
            // you can even do numbers
            // note: above string would need to also be boxed
            box 5
            box 3.2
            box true
        ]
    ]
]
Or maybe you want to define an attribute which builds another object from a list:
makeType "ParamOptions" [
    "label" ==> [
        "string list"
        nameof string
        object "ParamOptions"
    ]
]
Now you can build the schema (use Schema.buildToFile to directly write to a file).
{
    Interfaces = [
        makeType "SomeType" [
            "attr" ==> [
                nameof float
                nameof int
                [ // sublist = 'enums'
                    "x"
                    "y"
                ]
            ]
            "otherAttr" ==> [
                nameof string
            ]
        ]
    ]
} |> Schema.build
type ISomeTypeProp =
    interface end
[<Erase>]
module SomeType =
    [<Erase>]
    type attr =
        static member inline ofFloat(value: float) : ISomeTypeProp = unbox( "attr", value)
        static member inline ofInt(value: int) : ISomeTypeProp = unbox( "attr", value)
        static member inline x: ISomeTypeProp = unbox("attr", "x")
        static member inline y: ISomeTypeProp = unbox("attr", "y")
[<Erase>]
type SomeType =
    static member inline otherAttr(value: string) : ISomeTypeProp = unbox("otherAttr", value)
Non-Goals
We aren't intending to do EVERYTHING using the generator, just the attributes and annoying tedious template work.
We do want to support things like documenting props and adding the ability to alter how type names are handled/generated.
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
- 
                                                    net9.0- Fantomas.Core (>= 7.0.3)
- FSharp.Core (>= 9.0.303)
- Str (>= 0.19.0)
- YamlDotNet (>= 16.3.0)
 
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.