DynamicObj 3.1.0

DynamicObj

F# library supporting Dynamic Objects including inheritance in functional style.

The library is compatible with Fable, allowing transpilation to javascript and python.

Usage example

Get started

#r "nuget: DynamicObj"
#r "nuget: Fable.Core" // Needed if working with Fable

open DynamicObj
open Fable.Core // Needed if working with Fable

[<AttachMembers>] // AttachMembers needed if working with Fable
type Person(id : int, name : string) =
    
    // Include this in your class
    inherit DynamicObj()

    let mutable name = name

    // Mutable property
    member this.Name
        with get() = name
        and set(value) = name <- value

    // Immutable property
    member this.ID 
        with get() = id

let p = Person(1337,"John")

Accessing static and dynamic properties


// Access Static Properties
p.GetValue("Name") // val it: obj = "John"
p.GetValue("ID")   // val it: obj = 1337


// Overwrite mutable static property
p.SetValue("Name","Jane") // val it: unit = ()
// Overwrite immutable static property
p.SetValue("ID",1234) // System.Exception: Cannot set value for static, immutable property "ID"
// Set dynamic property
p.SetValue("Address","FunStreet") // val it: unit = ()


// Access Properties
p.GetValue("Name")    // val it: obj = "Jane"
p.Name                // val it: string = "Jane"
p.GetValue("ID")      // val it: obj = 1337
p.ID                  // val it: int = 1337
p.GetValue("Address") // val it: obj = "FunStreet"

Practical helpers

DynObj.format p
|> printfn "%s"

->

Name: Jane
ID: 1337
?Address: FunStreet

Development

Requirements

  • nodejs and npm
    • verify with node --version (Tested with v18.16.1)
    • verify with npm --version (Tested with v9.2.0)
  • .NET SDK
    • verify with dotnet --version (Tested with 7.0.306)
  • Python
    • verify with py --version (Tested with 3.12.2, known to work only for >=3.11)

Local Setup

On windows you can use the setup.cmd to run the following steps automatically!

  1. Setup dotnet tools

    dotnet tool restore

  2. Install NPM dependencies

    npm install

  3. Setup python environment

    py -m venv .venv

Verify correct setup with ./build.cmd runtests

Showing the top 20 packages that depend on DynamicObj.

Packages Downloads
Plotly.NET
plotly.js charts in .NET programming languages 📈🚀.
7
Plotly.NET
plotly.js charts in .NET programming languages 📈🚀.
6

Additions: add typed property retrieval function small changes according to PR add copyDynamicProperties create unified API for static and dynamic property accession Create manage-issues.yml Deletions: remove TryGetTypedValue member from transpilation remove poetry Bugfixes: fix python encoding issue fix python non-exisiting member accession

.NET Standard 2.0

Version Downloads Last updated
7.1.0 7 04/04/2026
7.0.1 6 04/04/2026
7.0.0 6 04/04/2026
6.0.0 6 04/04/2026
5.0.0 6 04/04/2026
4.0.3 7 04/04/2026
4.0.2 5 04/04/2026
4.0.1 5 04/04/2026
4.0.0 5 04/04/2026
3.1.0 6 04/04/2026
3.0.0 5 04/04/2026
2.0.0 7 04/04/2026
1.0.1 6 04/04/2026
1.0.0 7 04/04/2026
0.2.1 6 04/04/2026
0.2.0 6 04/04/2026
0.1.0 6 04/04/2026
0.0.3 5 04/04/2026
0.0.2 6 04/04/2026
0.0.1 5 04/04/2026