Skip to content

Commit

Permalink
Add release notes, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Sep 26, 2024
1 parent 3c9b1bf commit aa5f4a6
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 14,095 deletions.
8 changes: 5 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
"isRoot": true,
"tools": {
"fsdocs-tool": {
"version": "15.0.0",
"version": "20.0.1",
"commands": [
"fsdocs"
]
],
"rollForward": false
},
"fable": {
"version": "4.19.3",
"commands": [
"fable"
]
],
"rollForward": false
}
}
}
3 changes: 3 additions & 0 deletions .github/workflows/build-and-deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: build and deploy docs
on:
push:
branches: [ main ]
paths:
- 'src/**'
- 'docs/**'

jobs:
build-and-deploy-docs:
Expand Down
4 changes: 0 additions & 4 deletions DynamicObj.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".proj", ".proj", "{C3CF2F15
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{42AA66FC-8928-4029-BF41-52C1B49DEEDF}"
ProjectSection(SolutionItems) = preProject
docs\content\fsdocs-custom.css = docs\content\fsdocs-custom.css
docs\index.fsx = docs\index.fsx
docs\_template.fsx = docs\_template.fsx
docs\_template.html = docs\_template.html
docs\_template.ipynb = docs\_template.ipynb
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpTests", "tests\CSharpTests\CSharpTests.csproj", "{D62D0901-DB69-4C64-AC63-FBBBDCF6BC7D}"
Expand Down
73 changes: 8 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,19 @@ F# library supporting Dynamic Objects including inheritance in functional style.

The library is compatible with [Fable](https://github.com/fable-compiler/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?
## Usage example
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.

### Get started
DynamicObj is transpilable into JS and Python via [Fable](https://github.com/fable-compiler/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.

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

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

```fsharp
// 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

```fsharp
DynObj.format p
|> printfn "%s"
```
->
```
Name: Jane
ID: 1337
?Address: FunStreet
```
Documentation is hosted at https://csbiology.github.io/DynamicObj/

## Development

Expand Down
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### 4.0.0 (Released 2024-9-26)

- [Rework API naming](https://github.com/CSBiology/DynamicObj/pull/36)
- [Many improvements to DynObj API module](https://github.com/CSBiology/DynamicObj/pull/32)
- [Fix serialization with Newtonsoft.Json](https://github.com/CSBiology/DynamicObj/pull/37)
- [Add conditional compilation rules to transpilation-specific sections](https://github.com/CSBiology/DynamicObj/pull/38)

### 3.1.0+87113a4 (Released 2024-9-2)
* Additions:
* [[#e434c16](https://github.com/CSBiology/DynamicObj/commit/e434c162459b5c163bd387ef8b6aae4fbe6422cf)] add typed property retrieval function
Expand Down
Empty file removed docs/_template.fsx
Empty file.
90 changes: 0 additions & 90 deletions docs/_template.html

This file was deleted.

Empty file removed docs/_template.ipynb
Empty file.
Loading

0 comments on commit aa5f4a6

Please sign in to comment.