dynamitey-ci - FSharp.Interop.Dynamic 5.0.0-alpha171
dynamic operator using the DLR
PM> Install-Package FSharp.Interop.Dynamic -Version 5.0.0-alpha171 -Source https://www.myget.org/F/dynamitey-ci/api/v3/index.json
> nuget.exe install FSharp.Interop.Dynamic -Version 5.0.0-alpha171 -Source https://www.myget.org/F/dynamitey-ci/api/v3/index.json
> dotnet add package FSharp.Interop.Dynamic --version 5.0.0-alpha171 --source https://www.myget.org/F/dynamitey-ci/api/v3/index.json
source https://www.myget.org/F/dynamitey-ci/api/v3/index.json
nuget FSharp.Interop.Dynamic ~> 5.0.0-alpha171
Copy to clipboard
> choco install FSharp.Interop.Dynamic --version 5.0.0-alpha171 --source https://www.myget.org/F/dynamitey-ci/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "dynamitey-ci" -SourceLocation "https://www.myget.org/F/dynamitey-ci/api/v2"
Install-Module -Name "FSharp.Interop.Dynamic" -RequiredVersion "5.0.0-alpha171" -Repository "dynamitey-ci" -AllowPreRelease
Copy to clipboard
Browse the sources in this package using Visual Studio or WinDbg by configuring the following legacy symbol server URL: https://www.myget.org/F/dynamitey-ci/symbols/
FSharp.Interop.Dynamic
Test and coverage badges are the last green CI run on master. CI fails the PR if any test is skipped, line coverage drops below 77%, or branch coverage drops below 100%.
F# operators for the Dynamic Language Runtime. target?Name, target?Name <- value, and !?target are the F# spelling of C# dynamic, with piping and 'T option lookups.
Docs: fsprojects.github.io/FSharp.Interop.Dynamic
This library sits on Dynamitey 3.0.3. It is the F# surface, not Dynamitey itself.
F# has no dynamic keyword. Use this when the member is not known at compile time: Expando/JSON bags, optional fields, method names from config, C# APIs that return dynamic, pythonnet, COM. Use ordinary F# when the type is in your project. Full argument: Why this library.
Version story
6.0.0 is the current package: netstandard2.0 + net10.0, Dyn.tryGet / Dyn.exists. That is a TFM break from 5.0.1.268 (net45 / netstandard1.6 / netstandard2.0). netstandard2.0 still covers current .NET Framework and .NET.
Install (6.0.0)
dotnet add package FSharp.Interop.Dynamic
open FSharp.Interop.Dynamic
open FSharp.Interop.Dynamic.Operators // optional: ?+?, ?=?, …
Quick start
open System.Dynamic
open FSharp.Interop.Dynamic
let o = ExpandoObject()
o?Name <- "Ada"
let name: string = o?Name
let hello: string = "HelloWorld"?Substring(0, 5)
Annotate the result type when F# cannot infer it. Void CLR methods need unit:
let items = ResizeArray<string>()
let _: unit = items?Add("x")
Check a member without throwing
let present: string option = o |> Dyn.tryGet "Name" // Some "Ada"
let missing: string option = o |> Dyn.tryGet "NoSuch" // None
o |> Dyn.exists "Name" // true
o |> Dyn.exists "NoSuch" // false
Lookup is Dynamitey InvokeGet. A present null is still present. A present value that cannot convert to 'T still throws — that is not a miss.
Pipe through Dyn
o |> Dyn.set "Name" "Ada"
let name: string = o |> Dyn.get "Name"
let hello: string = "HelloWorld" |> Dyn.invokeMember "Substring" (0, 5)
Target is last so piping works.
Binary operators
open FSharp.Interop.Dynamic.Operators
let n: int = 5 ?+? 4
let f: float = 5 ?+? 3.5
let s: string = "Hello" ?+? " World"
[1; 2; 3; 4] |> List.reduce (?+?)
Direct invoke
let add3: int -> int = !?(+) 3
add3 4 // 7
What ? does
| You write | DLR |
|---|---|
target?Name when 'T is not a function |
InvokeGet |
target?Name when 'T is a function, then apply |
InvokeMember |
target?Name <- value |
InvokeSet |
!?target |
Invoke on the target itself |
That is why target?Foo(1, 2) is a method call: application forces a function type.
Dynamitey
6.0.0 references Dynamitey 3.0.3. tryGet / exists do not wait on Dynamitey 4.0.0. The community continuation of Dynamitey is dynamitey-community/dynamitey; switching this package to it is #29.
You can still open Dynamitey for Build, Dynamic.Curry, DynamicObjects.Dictionary.
Caveats
- The DLR cannot see explicit interface members (same as C#
dynamic). - Not trim-safe or NativeAOT-safe.
- 15 or more arguments throw
TypeLoadException(ImpromptuInterface was never shipped). Fourteen work. - C# optional parameters must all be passed. The DLR does not fill defaults.
tryGet/existson a null target throwNullReferenceException(notNone/false).- Do not build member names from untrusted input. SECURITY.md.
- Historical: .NET Core 2.0.0–2.0.2 broke
dynamicon nested types inside generics (#11). Current TFMs are fine.
Full list: Caveats.
Every F# snippet above is a test in Tests/ReadmeExamples.fs. pythonnet and SignalR sketches live on the why page and are not compiled here.
Build
Requires the .NET 10 SDK.
dotnet restore
dotnet build -c Release -warnaserror
dotnet test --project Tests/Tests.fsproj -c Release
Docs: dotnet tool install -g docfx --version 2.78.5, then dotnet build FSharp.Interop.Dynamic/FSharp.Interop.Dynamic.fsproj -c Release && docfx docfx/docfx.json.
Release: add the version's section to CHANGELOG.md, then tag v6.0.0 and push. Releasing.
Feedback and contributing
- Bugs and feature requests: open an issue. Include the F# and .NET versions and a minimal snippet.
- Security problems: do not open a public issue. Follow SECURITY.md.
- Code and docs: pull requests are welcome. CONTRIBUTING.md covers the process and what a PR needs before it merges.
Maintainers
fsprojects default: @fsprojectsgit.
-
.NETFramework 4.5
- Dynamitey (>= 2.0.9.136)
- FSharp.Core (>= 4.2.3)
- Microsoft.CSharp (>= 4.4.1)
-
.NETStandard 1.6
- Dynamitey (>= 2.0.9.136)
- FSharp.Core (>= 4.2.3)
- Microsoft.CSharp (>= 4.4.1)
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 2.0
- Dynamitey (>= 2.0.9.136)
- FSharp.Core (>= 4.2.3)
- Microsoft.CSharp (>= 4.4.1)
- .NETFramework 4.5: 4.5.0.0
- .NETStandard 1.6: 1.6.0.0
- .NETStandard 2.0: 2.0.0.0
| Assembly | Assembly hash | Match |
|---|---|---|
| /lib/netstandard1.6/fsharp.interop.dynamic.dll | d5013257c58241b2b79c99c33567d2dbFFFFFFFF | |
| /lib/net45/fsharp.interop.dynamic.dll | e9204a39793448ec99e3bbaddba733e2FFFFFFFF | |
| /lib/netstandard2.0/fsharp.interop.dynamic.dll | ef3519a09a5549b59cf93808c5d9edfeFFFFFFFF |
OwnersJay Tuley |
AuthorsJay Tuley |
Project URLhttps://github.com/fsprojects/FSharp.Interop.Dynamic |
LicenseApache-2.0 |
Tagsfsharp dynamic dlr |
Info12017 total downloads |
| 157 downloads for version 5.0.0-alpha171 |
| Download (37.35 KB) |
| Download legacy symbols (49.98 KB) |
| Found on the current feed only |
Package history
| Version | Size | Last updated | Downloads | Mirrored? | |||
|---|---|---|---|---|---|---|---|
|
|
5.0.1.269 | 53.33 KB | Thu, 03 Oct 2019 05:01:29 GMT | 155 |
|
||
|
|
5.0.1.268 | 53.33 KB | Thu, 03 Oct 2019 04:52:08 GMT | 161 |
|
||
|
|
5.0.1-alpha272 | 50.72 KB | Thu, 03 Oct 2019 05:21:08 GMT | 166 |
|
||
|
|
5.0.1-alpha271 | 50.72 KB | Thu, 03 Oct 2019 05:16:38 GMT | 144 |
|
||
|
|
5.0.1-alpha270 | 50.5 KB | Thu, 03 Oct 2019 05:12:01 GMT | 162 |
|
||
|
|
5.0.1-alpha267 | 50.49 KB | Thu, 03 Oct 2019 04:47:39 GMT | 146 |
|
||
|
|
5.0.0.251 | 53.15 KB | Wed, 11 Sep 2019 21:56:11 GMT | 158 |
|
||
|
|
5.0.0.250 | 53.16 KB | Wed, 11 Sep 2019 21:48:31 GMT | 162 |
|
||
|
|
5.0.0-alpha266 | 50.48 KB | Thu, 03 Oct 2019 04:42:43 GMT | 151 |
|
||
|
|
5.0.0-alpha265 | 50.48 KB | Thu, 03 Oct 2019 04:28:27 GMT | 166 |
|
||
|
|
5.0.0-alpha264 | 50.49 KB | Thu, 03 Oct 2019 04:12:24 GMT | 172 |
|
||
|
|
5.0.0-alpha262 | 50.49 KB | Thu, 03 Oct 2019 03:58:39 GMT | 146 |
|
||
|
|
5.0.0-alpha257 | 50.29 KB | Wed, 02 Oct 2019 21:54:33 GMT | 164 |
|
||
|
|
5.0.0-alpha256 | 50.29 KB | Wed, 02 Oct 2019 21:19:46 GMT | 171 |
|
||
|
|
5.0.0-alpha255 | 50.29 KB | Wed, 02 Oct 2019 21:15:22 GMT | 154 |
|
||
|
|
5.0.0-alpha254 | 50.29 KB | Wed, 02 Oct 2019 21:10:59 GMT | 164 |
|
||
|
|
5.0.0-alpha253 | 50.3 KB | Wed, 02 Oct 2019 21:00:39 GMT | 160 |
|
||
|
|
5.0.0-alpha252 | 50.31 KB | Wed, 02 Oct 2019 20:36:41 GMT | 169 |
|
||
|
|
5.0.0-alpha249 | 50.31 KB | Wed, 11 Sep 2019 21:28:01 GMT | 162 |
|
||
|
|
5.0.0-alpha248 | 46.89 KB | Wed, 11 Sep 2019 21:15:55 GMT | 159 |
|
||
|
|
5.0.0-alpha247 | 46.89 KB | Mon, 03 Dec 2018 17:02:11 GMT | 167 |
|
||
|
|
5.0.0-alpha243 | 46.98 KB | Thu, 07 Jun 2018 03:07:41 GMT | 152 |
|
||
|
|
5.0.0-alpha241 | 46.99 KB | Thu, 07 Jun 2018 02:51:45 GMT | 162 |
|
||
|
|
5.0.0-alpha239 | 46.99 KB | Thu, 07 Jun 2018 02:40:17 GMT | 154 |
|
||
|
|
5.0.0-alpha238 | 45.19 KB | Thu, 24 May 2018 23:20:30 GMT | 160 |
|
||
|
|
5.0.0-alpha236 | 45.19 KB | Thu, 24 May 2018 23:12:54 GMT | 151 |
|
||
|
|
5.0.0-alpha234 | 45.19 KB | Thu, 24 May 2018 23:06:47 GMT | 146 |
|
||
|
|
5.0.0-alpha232 | 45.19 KB | Thu, 24 May 2018 22:49:43 GMT | 162 |
|
||
|
|
5.0.0-alpha231 | 45.19 KB | Thu, 24 May 2018 22:39:30 GMT | 148 |
|
||
|
|
5.0.0-alpha229 | 45.19 KB | Thu, 24 May 2018 22:27:15 GMT | 155 |
|
||
|
|
5.0.0-alpha227 | 45.19 KB | Thu, 24 May 2018 22:09:51 GMT | 170 |
|
||
|
|
5.0.0-alpha219 | 45.19 KB | Thu, 24 May 2018 17:03:40 GMT | 143 |
|
||
|
|
5.0.0-alpha217 | 45.19 KB | Thu, 24 May 2018 16:37:24 GMT | 160 |
|
||
|
|
5.0.0-alpha215 | 45.13 KB | Thu, 24 May 2018 16:20:33 GMT | 157 |
|
||
|
|
5.0.0-alpha213 | 45.04 KB | Thu, 24 May 2018 14:15:14 GMT | 127 |
|
||
|
|
5.0.0-alpha211 | 42.61 KB | Wed, 23 May 2018 20:56:22 GMT | 140 |
|
||
|
|
5.0.0-alpha209 | 41.6 KB | Wed, 23 May 2018 20:23:28 GMT | 155 |
|
||
|
|
5.0.0-alpha207 | 41.62 KB | Wed, 23 May 2018 17:22:28 GMT | 155 |
|
||
|
|
5.0.0-alpha205 | 37.36 KB | Wed, 23 May 2018 14:14:55 GMT | 153 |
|
||
|
|
5.0.0-alpha203 | 37.34 KB | Wed, 23 May 2018 05:51:09 GMT | 165 |
|
||
|
|
5.0.0-alpha199 | 37.34 KB | Wed, 23 May 2018 05:31:12 GMT | 156 |
|
||
|
|
5.0.0-alpha198 | 37.35 KB | Wed, 23 May 2018 05:28:28 GMT | 156 |
|
||
|
|
5.0.0-alpha195 | 37.34 KB | Wed, 23 May 2018 05:17:50 GMT | 152 |
|
||
|
|
5.0.0-alpha193 | 37.34 KB | Wed, 23 May 2018 05:12:28 GMT | 167 |
|
||
|
|
5.0.0-alpha191 | 37.35 KB | Wed, 23 May 2018 05:06:56 GMT | 154 |
|
||
|
|
5.0.0-alpha189 | 37.34 KB | Wed, 23 May 2018 05:02:55 GMT | 146 |
|
||
|
|
5.0.0-alpha187 | 37.34 KB | Wed, 23 May 2018 04:53:05 GMT | 152 |
|
||
|
|
5.0.0-alpha185 | 37.34 KB | Wed, 23 May 2018 04:40:25 GMT | 149 |
|
||
|
|
5.0.0-alpha183 | 37.34 KB | Wed, 23 May 2018 04:34:24 GMT | 151 |
|
||
|
|
5.0.0-alpha181 | 37.34 KB | Wed, 23 May 2018 04:18:38 GMT | 149 |
|
||
|
|
5.0.0-alpha179 | 37.34 KB | Wed, 23 May 2018 04:05:03 GMT | 146 |
|
||
|
|
5.0.0-alpha177 | 37.34 KB | Wed, 23 May 2018 03:57:55 GMT | 149 |
|
||
|
|
5.0.0-alpha175 | 37.34 KB | Wed, 23 May 2018 03:45:40 GMT | 156 |
|
||
|
|
5.0.0-alpha173 | 37.34 KB | Wed, 23 May 2018 03:41:17 GMT | 152 |
|
||
|
|
5.0.0-alpha171 | 37.35 KB | Wed, 23 May 2018 03:26:35 GMT | 157 |
|
||
|
|
5.0.0-alpha169 | 37.34 KB | Wed, 23 May 2018 03:09:43 GMT | 127 |
|
||
|
|
5.0.0-alpha167 | 37.34 KB | Wed, 23 May 2018 03:03:04 GMT | 160 |
|
||
|
|
5.0.0-alpha165 | 37.34 KB | Wed, 23 May 2018 02:58:51 GMT | 155 |
|
||
|
|
5.0.0-alpha163 | 37.34 KB | Wed, 23 May 2018 02:44:47 GMT | 133 |
|
||
|
|
5.0.0-alpha161 | 37.34 KB | Wed, 23 May 2018 02:12:49 GMT | 148 |
|
||
|
|
5.0.0-alpha159 | 37.34 KB | Wed, 23 May 2018 01:52:48 GMT | 152 |
|
||
|
|
5.0.0-alpha157 | 37.34 KB | Wed, 23 May 2018 01:47:48 GMT | 163 |
|
||
|
|
5.0.0-alpha155 | 37.34 KB | Tue, 22 May 2018 15:22:51 GMT | 157 |
|
||
|
|
5.0.0-alpha153 | 25.53 KB | Tue, 22 May 2018 13:08:48 GMT | 167 |
|
||
|
|
5.0.0-alpha151 | 25.54 KB | Tue, 22 May 2018 04:08:51 GMT | 153 |
|
||
|
|
4.1.0-alpha135 | 38.15 KB | Wed, 09 May 2018 04:19:14 GMT | 139 |
|
||
|
|
4.0.4-alpha134 | 24.59 KB | Sun, 29 Apr 2018 21:51:11 GMT | 142 |
|
||
|
|
4.0.3.131 | 26.8 KB | Thu, 05 Apr 2018 06:26:00 GMT | 143 |
|
||
|
|
4.0.3.130 | 26.81 KB | Thu, 05 Apr 2018 06:22:31 GMT | 149 |
|
||
|
|
4.0.3-beta97 | 24.17 KB | Sat, 19 Aug 2017 02:43:36 GMT | 162 |
|
||
|
|
4.0.3-beta95 | 24.17 KB | Sat, 19 Aug 2017 02:38:38 GMT | 152 |
|
||
|
|
4.0.3-alpha99 | 24.16 KB | Tue, 19 Dec 2017 19:29:23 GMT | 157 |
|
||
|
|
4.0.3-alpha98 | 24.17 KB | Tue, 19 Dec 2017 19:25:13 GMT | 140 |
|
||
|
|
4.0.3-alpha94 | 24.18 KB | Sat, 19 Aug 2017 02:30:01 GMT | 151 |
|
||
|
|
4.0.3-alpha83 | 24.23 KB | Thu, 17 Aug 2017 21:16:27 GMT | 167 |
|
||
|
|
4.0.3-alpha133 | 24.59 KB | Thu, 05 Apr 2018 06:27:42 GMT | 148 |
|
||
|
|
4.0.3-alpha126 | 24.59 KB | Thu, 05 Apr 2018 05:31:13 GMT | 128 |
|
||
|
|
4.0.3-alpha121 | 24.62 KB | Tue, 20 Mar 2018 06:20:21 GMT | 158 |
|