DynamicObj 6.0.0

dotnet add package DynamicObj --version 6.0.0                
NuGet\Install-Package DynamicObj -Version 6.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DynamicObj" Version="6.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DynamicObj --version 6.0.0                
#r "nuget: DynamicObj, 6.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DynamicObj as a Cake Addin
#addin nuget:?package=DynamicObj&version=6.0.0

// Install DynamicObj as a Cake Tool
#tool nuget:?package=DynamicObj&version=6.0.0                

DynamicObj

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

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

The primary use case of DynamicObj is the extension of F# classes with dynamic properties. This is useful when you want to add arbitrarily typed properties to a class at runtime.

Why would you want to do that?

Yes, The type system is one of the core strengths of F#, and it is awesome. However, there are cases where a static domain model is either unfeasible or not flexible enough, especially when interfacing with dynamic languages such as JavaScript or Python.

DynamicObj is transpilable into JS and Python via Fable, meaning you can use it to create classes that are usable in both .NET and those languages, while making their usage (e.g., the setting of dynamic properties) both safe in .NET and idiomatic in JS/Python.

Docs

Documentation is hosted at https://csbiology.github.io/DynamicObj/

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on DynamicObj:

Package Downloads
Plotly.NET

plotly.js charts in .NET programming languages 📈🚀.

ARCtrl.CWL

ARC helper functions for Common workflow language.

Cyjs.NET

.NET interface for Cytoscape.js written in F#

Dash.NET

Dotnet interface for Dash - the most downloaded framework for building ML and data science web apps - written in F#. This package contains the core implementation of dash for .NET such as callbacks, html and core components.

ProteomIQon

ProteomIQon - computational proteomics

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.0 0 1/27/2025
5.0.0 268 12/17/2024
4.0.3 4,410 10/16/2024
4.0.2 102 10/15/2024
4.0.1 214 10/15/2024
4.0.0 764 9/26/2024
3.1.0 1,421 9/2/2024
3.0.0 397 8/23/2024
2.0.0 306,056 5/31/2022
1.0.1 38,063 1/13/2022
1.0.0 455 1/13/2022
0.2.1 706 10/13/2021
0.2.0 19,140 9/10/2021
0.1.0 401 8/18/2021
0.0.3 23,022 4/16/2021
0.0.2 354 4/16/2021
0.0.1 863 1/27/2021

Breaking changes.
Closed issues:
- [Deep copy: add native fallbacks for objects in js/py](https://github.com/CSBiology/DynamicObj/issues/47)
- [Expand DeepCopy logic to mutable collections that contain primitives](https://github.com/CSBiology/DynamicObj/issues/45)
- [Add a flag for DeepCopyPropertiesTo that enabled to omit static props](https://github.com/CSBiology/DynamicObj/issues/44])
Improve `DynamicObj` deep copy methods and refactor into a separate `CopyUtils` class for reuse:
The following types/classes can be (recursively) deep copied now:
- Basic F# types (`bool`, `byte`, `sbyte`, `int16`, `uint16`, `int`, `uint`, `int64`, `uint64`, `nativeint`, `unativeint`, `float`, `float32`, `char`, `string`, `unit`, `decimal`)
- `ResizeArrays` and `Dictionaries` containing any combination of basic F# types
- `Dictionaries` containing `DynamicObj` as keys or values in any combination with `DynamicObj` or basic F# types as keys or values
- `array<DynamicObj>`, `list<DynamicObj>`, `ResizeArray<DynamicObj>`: These collections of DynamicObj are copied as a new collection with recursively deep copied elements.
- `System.ICloneable`: If the property implements `ICloneable`, the `Clone()` method is called on the property.
- `DynamicObj` (and derived classes): properties that are themselves `DynamicObj` instances are deep copied recursively.
if a derived class has static properties (e.g. instance properties), these can be copied as dynamic properties on the new instance or ignored.
Note on Classes that inherit from `DynamicObj`:
Classes that inherit from DynamicObj will match the `DynamicObj` typecheck if they do not implement `ICloneable`.
The deep copied instances will be cast to `DynamicObj` with deep copied dynamic properties. Staic/instance properties can be copied as dynamic properties on the new instance or be ignored.
It should be possible to 'recover' the original type by checking if the needed properties exist as dynamic properties,
and then passing them to the class constructor if needed.