37 |
38 |
FSharp.Interop.Dynamic 
39 |
The F# Dynamic Operator, powered by the DLR. Compiled for .NET Standard 2.0, .NET Standard 1.6, .NET Framework 4.5
40 |
Install from NuGet
41 |
1:
42 | |
43 | PM> Install-Package FSharp.Interop.Dynamic
44 |
|
45 |
46 |
47 |
Build Status
48 |
49 |
50 |
54 |
55 |
56 |
57 | Nuget Deployment |
58 | 
|
59 |
60 |
61 | Mac/Linux/Windows |
62 | 
|
63 |
64 |
65 | Coverage |
66 | 
|
67 |
68 |
69 |
70 |
71 |
Bleeding edge feed on MyGet
72 |

73 |
Usage
74 |
target?Property
, target?Property<-value
, and target?Method(arg,arg2)
allow you to dynamically get/set properties and call methods
75 |
Also Dyn.implicitConvert
,Dyn.explicitConvert
, comparison operators and more.
76 |
Examples:
77 |
System.Dynamic
78 |
1:
79 | 2:
80 | 3:
81 | 4:
82 | |
83 | open FSharp.Interop.Dynamic
84 | let ex1 = ExpandoObject()
85 | ex1?Test<-"Hi"//Set Dynamic Property
86 | ex1?Test //Get Dynamic
87 |
|
88 |
89 |
90 |
MVC ViewBag
91 |
1:
92 | |
93 | x.ViewBag?Name<-"George"
94 |
|
95 |
96 |
97 |
Dynamitey
98 |
1:
99 | 2:
100 | 3:
101 | 4:
102 | 5:
103 | 6:
104 | 7:
105 | 8:
106 | 9:
107 | 10:
108 | 11:
109 | |
110 | open FSharp.Interop.Dynamic
111 | open Dynamitey.DynamicObjects
112 |
113 | let ComBinder = LateType("System.Dynamic.ComBinder, System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
114 |
115 | let getPropertyNames (target:obj) =
116 | seq {
117 | yield! target.GetType().GetTypeInfo().GetProperties().Select(fun it -> it.Name)
118 | if (ComBinder.IsAvailable) then
119 | yield! ComBinder?GetDynamicDataMemberNames(target)
120 | }
121 |
|
122 |
123 |
124 |
Python Interop
125 |
1:
126 | 2:
127 | 3:
128 | 4:
129 | 5:
130 | 6:
131 | 7:
132 | 8:
133 | 9:
134 | 10:
135 | |
136 | open Python.Runtime
137 | open FSharp.Interop.Dynamic
138 | open FSharp.Interop.Dynamic.Operators
139 | do
140 | use __ = Py.GIL()
141 | let math = Py.Import(
142 | math?cos(math?pi ?*? 2) |> printfn
143 | let sin = math?sin
144 | sin 5 |> printfn
145 | math?cos(5) ?+? sin(5) |> printfn
146 |
|
147 |
148 |
149 |
SignalR (.net framework version)
150 |
1:
151 | 2:
152 | 3:
153 | 4:
154 | 5:
155 | |
156 | open FSharp.Interop.Dynamic
157 | type MyHub =
158 | inherit Hub
159 | member x.Send (name : string) (message : string) =
160 | base.Clients.All?addMessage(name,message) |> ignore
161 |
|
162 |
163 |
164 |
Caveats:
165 |
The DLR
is incompatible with interface explicit members, so are these operators, just like C#'s dynamic
keyword.
166 |
.NET Core 2.0.0 to 2.0.2 had a major bug in the C# dynamic keyword with nested classes inside of generic classes.. You will know it from a substring argument length exception. .NET Framework 4.0+, .NET Core 1.x and .NET Core 2.0.3+ and later are unaffected.
167 |
Maintainer(s)
168 |
172 |
The default maintainer account for projects under "fsprojects" is @fsprojectsgit - F# Community Project Incubation Space (repo management)
173 |
174 |
Multiple items
namespace FSharp
--------------------
namespace Microsoft.FSharp
175 |
namespace FSharp.Interop
176 |
namespace FSharp.Interop.Dynamic
177 |
val ex1 : obj
178 |
val ComBinder : obj
179 |
val getPropertyNames : target:obj -> seq<'a>
180 |
val target : obj
181 |
type obj = System.Object
182 |
Multiple items
val seq : sequence:seq<'T> -> seq<'T>
--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>
183 |
System.Object.GetType() : System.Type
184 |
module Operators
from FSharp.Interop.Dynamic
185 |
val __ : 'a (requires 'a :> System.IDisposable)
186 |
val math : 'a
187 |
val cos : value:'T -> 'T (requires member Cos)
188 |
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
189 |
val sin : value:'T -> 'T (requires member Sin)
190 |
Multiple items
val string : value:'T -> string
--------------------
type string = System.String
191 |
val ignore : value:'T -> unit
192 |
193 |