@nfdi4plants/arctrl 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/ARC.js +103 -12
  2. package/CWL/CWLTypes.js +2 -2
  3. package/CWL/Decode.js +2 -2
  4. package/CWL/Inputs.js +2 -2
  5. package/CWL/Outputs.js +2 -2
  6. package/CWL/Requirements.js +2 -2
  7. package/CWL/ToolDescription.js +1 -1
  8. package/CWL/WorkflowDescription.js +1 -1
  9. package/CWL/WorkflowSteps.js +1 -1
  10. package/ColumnIndex.js +258 -0
  11. package/Conversion.js +1679 -0
  12. package/Core/Data.js +28 -3
  13. package/Core/DataFile.js +19 -3
  14. package/Core/Helper/Collections.js +107 -4
  15. package/Core/Helper/DateTime.js +17 -0
  16. package/Core/Helper/ORCID.js +39 -0
  17. package/Json/Decode.js +3 -3
  18. package/Json/Encode.js +9 -0
  19. package/Json/OntologySourceReference.js +4 -4
  20. package/Json/ROCrate/LDContext.js +121 -0
  21. package/Json/ROCrate/LDGraph.js +87 -0
  22. package/Json/{LDObject.js → ROCrate/LDNode.js} +55 -46
  23. package/Json/ROCrate/LDRef.js +25 -0
  24. package/Json/ROCrate/LDValue.js +66 -0
  25. package/JsonIO/LDObject.js +30 -5
  26. package/ROCrate/ArcROCrateMetadata.js +14 -13
  27. package/ROCrate/Generic/Comment.js +115 -0
  28. package/ROCrate/Generic/Dataset.js +669 -0
  29. package/ROCrate/Generic/DefinedTerm.js +115 -0
  30. package/ROCrate/Generic/File.js +200 -0
  31. package/ROCrate/Generic/LabProcess.js +238 -0
  32. package/ROCrate/Generic/LabProtocol.js +275 -0
  33. package/ROCrate/Generic/Organization.js +71 -0
  34. package/ROCrate/Generic/Person.js +411 -0
  35. package/ROCrate/Generic/PostalAddress.js +159 -0
  36. package/ROCrate/Generic/PropertyValue.js +548 -0
  37. package/ROCrate/Generic/Sample.js +139 -0
  38. package/ROCrate/Generic/ScholarlyArticle.js +187 -0
  39. package/ROCrate/Helper.js +6 -0
  40. package/ROCrate/ISAProfile/Assay.js +3 -3
  41. package/ROCrate/ISAProfile/Data.js +7 -7
  42. package/ROCrate/ISAProfile/Dataset.js +7 -6
  43. package/ROCrate/ISAProfile/Investigation.js +3 -3
  44. package/ROCrate/ISAProfile/LabProcess.js +7 -7
  45. package/ROCrate/ISAProfile/LabProtocol.js +7 -7
  46. package/ROCrate/ISAProfile/Person.js +7 -7
  47. package/ROCrate/ISAProfile/PropertyValue.js +7 -7
  48. package/ROCrate/ISAProfile/Sample.js +7 -7
  49. package/ROCrate/ISAProfile/ScholarlyArticle.js +7 -7
  50. package/ROCrate/ISAProfile/Study.js +3 -3
  51. package/ROCrate/LDContext.js +283 -0
  52. package/ROCrate/LDObject.js +902 -36
  53. package/ROCrate/ROCrateContext.js +44 -0
  54. package/ROCrateIO.js +62 -0
  55. package/Spreadsheet/DataMapTable/DataMapHeader.js +3 -2
  56. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/DynObj.fs +31 -1
  57. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/DynObj.fs.js +30 -1
  58. package/fable_modules/DynamicObj.7.0.1/DynamicObj.fs +1025 -0
  59. package/fable_modules/DynamicObj.7.0.1/DynamicObj.fs.js +433 -0
  60. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/FableJS.fs +16 -0
  61. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/FablePy.fs +14 -0
  62. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/HashCodes.fs +15 -0
  63. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/HashCodes.fs.js +4 -0
  64. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Debug/netstandard2.0/DynamicObj.AssemblyInfo.fs +1 -1
  65. package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Release/netstandard2.0/DynamicObj.AssemblyInfo.fs +3 -3
  66. package/fable_modules/project_cracked.json +1 -1
  67. package/package.json +1 -1
  68. package/Json/ARC.js +0 -31
  69. package/JsonIO/ARC.js +0 -31
  70. package/fable_modules/DynamicObj.4.0.3/DynamicObj.fs +0 -310
  71. package/fable_modules/DynamicObj.4.0.3/DynamicObj.fs.js +0 -166
  72. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/DynamicObj.fableproj +0 -0
  73. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/FableJS.fs.js +0 -0
  74. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/PropertyHelper.fs +0 -0
  75. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/PropertyHelper.fs.js +0 -0
  76. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/ReflectionUtils.fs +0 -0
  77. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/ReflectionUtils.fs.js +0 -0
  78. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Debug/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +0 -0
  79. /package/fable_modules/{DynamicObj.4.0.3 → DynamicObj.7.0.1}/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +0 -0
@@ -0,0 +1,1025 @@
1
+ namespace DynamicObj
2
+
3
+ #if !FABLE_COMPILER
4
+ open System.Dynamic
5
+ #endif
6
+
7
+ open System.Collections.Generic
8
+ open Fable.Core
9
+
10
+ [<AttachMembers>]
11
+ type DynamicObj() =
12
+
13
+ #if !FABLE_COMPILER
14
+ inherit DynamicObject()
15
+ #endif
16
+
17
+ let mutable properties = new Dictionary<string, obj>()
18
+
19
+ /// <summary>
20
+ /// A dictionary of dynamic boxed properties
21
+ /// </summary>
22
+ member this.Properties
23
+ with get() = properties
24
+ and internal set(value) = properties <- value
25
+
26
+ /// <summary>
27
+ /// Creates a new DynamicObj from a Dictionary containing dynamic properties.
28
+ /// </summary>
29
+ /// <param name="dynamicProperties">The dictionary with the dynamic properties</param>
30
+ static member ofDict (dynamicProperties: Dictionary<string,obj>) =
31
+ let obj = DynamicObj()
32
+ obj.Properties <- dynamicProperties
33
+ obj
34
+
35
+ /// <summary>
36
+ /// Returns Some(PropertyHelper) if a static property with the given name exists, otherwise None.
37
+ /// </summary>
38
+ /// <param name="propertyName">The name of the property to get the PropertyHelper for</param>
39
+ member this.TryGetStaticPropertyHelper (propertyName: string) : PropertyHelper option =
40
+ ReflectionUtils.tryGetStaticPropertyInfo this propertyName
41
+
42
+ /// <summary>
43
+ /// Returns Some(PropertyHelper) if a dynamic property with the given name exists, otherwise None.
44
+ /// </summary>
45
+ /// <param name="propertyName">The name of the property to get the PropertyHelper for</param>
46
+ member this.TryGetDynamicPropertyHelper (propertyName: string) : PropertyHelper option =
47
+ #if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
48
+ FableJS.tryGetDynamicPropertyHelper this propertyName
49
+ #endif
50
+ #if FABLE_COMPILER_PYTHON
51
+ FablePy.tryGetDynamicPropertyHelper this propertyName
52
+ #endif
53
+ #if !FABLE_COMPILER
54
+ match properties.TryGetValue propertyName with
55
+ | true,_ ->
56
+ Some {
57
+ Name = propertyName
58
+ IsStatic = false
59
+ IsDynamic = true
60
+ IsMutable = true
61
+ IsImmutable = false
62
+ GetValue = fun o -> properties.[propertyName]
63
+ SetValue = fun o v -> properties.[propertyName] <- v
64
+ RemoveValue = fun o -> properties.Remove(propertyName) |> ignore
65
+ }
66
+ | _ -> None
67
+ #endif
68
+
69
+ /// <summary>
70
+ /// Returns Some(PropertyHelper) if a property (static or dynamic) with the given name exists, otherwise None.
71
+ /// </summary>
72
+ /// <param name="propertyName">The name of the property to get the PropertyHelper for</param>
73
+ member this.TryGetPropertyHelper (propertyName: string) : PropertyHelper option =
74
+ match this.TryGetStaticPropertyHelper propertyName with
75
+ | Some pi -> Some pi
76
+ | None -> this.TryGetDynamicPropertyHelper propertyName
77
+
78
+ /// <summary>
79
+ /// Returns Some(boxed property value) if a dynamic (or static) property with the given name exists, otherwise None.
80
+ /// </summary>
81
+ /// <param name="name">the name of the property to get</param>
82
+ member this.TryGetPropertyValue (propertyName: string) =
83
+ // first check the Properties collection for member
84
+ this.TryGetPropertyHelper(propertyName)
85
+ |> Option.map (fun pi -> pi.GetValue(this))
86
+
87
+ /// <summary>
88
+ /// Returns the boxed property value of the dynamic (or static) property with the given name.
89
+ /// </summary>
90
+ /// <param name="propertyName">the name of the property to get</param>
91
+ /// <exception cref="System.MissingMemberException">Thrown if no dynamic or static property with the given name exists</exception>
92
+ member this.GetPropertyValue (propertyName: string) =
93
+ match this.TryGetPropertyValue(propertyName) with
94
+ | Some value -> value
95
+ | None -> raise <| System.MissingMemberException($"No dynamic or static property \"{propertyName}\" does exist on object.")
96
+
97
+ #if !FABLE_COMPILER
98
+
99
+ /// <summary>
100
+ /// Returns Some('TPropertyValue) when a dynamic (or static) property with the given name and type exists, otherwise None.
101
+ ///
102
+ /// This method is not Fable-compatible and can therefore not be used in code that will be transpiled.
103
+ /// </summary>
104
+ /// <param name="propertyName">the name of the property to get</param>
105
+ /// <remarks>This method is not Fable-compatible and can therefore not be used in code that will be transpiled.</remarks>
106
+ member this.TryGetTypedPropertyValue<'TPropertyValue> (propertyName: string) =
107
+
108
+ match (this.TryGetPropertyValue propertyName) with
109
+ | None -> None
110
+ | Some o ->
111
+ match o with
112
+ | :? 'TPropertyValue as o -> o |> Some
113
+ | _ -> None
114
+ #endif
115
+
116
+
117
+ /// <summary>
118
+ /// Sets the dynamic (or static) property value with the given name, creating a new dynamic property if none exists.
119
+ /// </summary>
120
+ /// <param name="propertyName">the name of the property to set</param>
121
+ /// <param name="propertyValue">the value of the property to set</param>
122
+ member this.SetProperty (
123
+ propertyName: string,
124
+ propertyValue: obj
125
+ ) =
126
+ // first check to see if there's a native property to set
127
+ match this.TryGetStaticPropertyHelper propertyName with
128
+ | Some pi ->
129
+ if pi.IsMutable then
130
+ pi.SetValue this propertyValue
131
+ else
132
+ failwith $"Cannot set value for static, immutable property \"{propertyName}\""
133
+ | None ->
134
+ #if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
135
+ FableJS.setPropertyValue this propertyName propertyValue
136
+ #endif
137
+ #if FABLE_COMPILER_PYTHON
138
+ FablePy.setPropertyValue this propertyName propertyValue
139
+ #endif
140
+ #if !FABLE_COMPILER
141
+ // Next check the Properties collection for member
142
+ match properties.TryGetValue propertyName with
143
+ | true,_ -> properties.[propertyName] <- propertyValue
144
+ | _ -> properties.Add(propertyName,propertyValue)
145
+ #endif
146
+
147
+ /// <summary>
148
+ /// Removes any dynamic property with the given name from the input DynamicObj.
149
+ /// If the property is static and mutable, it will be set to null.
150
+ /// Static immutable properties cannot be removed.
151
+ /// </summary>
152
+ /// <param name="propertyName">the name of the property to remove</param>
153
+ /// <exception cref="System.MemberAccessException">Thrown if the dynamic property does not exist</exception>
154
+ member this.RemoveProperty (propertyName: string) =
155
+ match this.TryGetPropertyHelper propertyName with
156
+ | Some pi when pi.IsMutable ->
157
+ pi.RemoveValue this
158
+ true
159
+ | Some _ ->
160
+ raise <| System.MemberAccessException($"Cannot remove value for static, immutable property \"{propertyName}\"")
161
+ | None -> false
162
+
163
+ /// <summary>
164
+ /// Returns PropertyHelpers for all dynamic properties of the DynamicObj.
165
+ ///
166
+ /// When includeInstanceProperties is set to true, instance properties (= 'static' properties on the class) are included in the result.
167
+ /// </summary>
168
+ /// <param name="includeInstanceProperties">whether to include instance properties (= 'static' properties on the class)</param>
169
+ member this.GetPropertyHelpers (includeInstanceProperties: bool) =
170
+ #if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
171
+ FableJS.getPropertyHelpers this
172
+ |> Seq.filter (fun pd ->
173
+ includeInstanceProperties || pd.IsDynamic
174
+ )
175
+ #endif
176
+ #if FABLE_COMPILER_PYTHON
177
+ FablePy.getPropertyHelpers this
178
+ |> Seq.filter (fun pd ->
179
+ includeInstanceProperties || pd.IsDynamic
180
+ )
181
+ #endif
182
+ #if !FABLE_COMPILER
183
+ seq [
184
+ if includeInstanceProperties then
185
+ yield! ReflectionUtils.getStaticProperties (this)
186
+ for key in properties.Keys ->
187
+ {
188
+ Name = key
189
+ IsStatic = false
190
+ IsDynamic = true
191
+ IsMutable = true
192
+ IsImmutable = false
193
+ GetValue = fun o -> properties.[key]
194
+ SetValue = fun o v -> properties.[key] <- v
195
+ RemoveValue = fun o -> properties.Remove(key) |> ignore
196
+ }
197
+ ]
198
+ #endif
199
+ |> Seq.filter (fun p -> p.Name.ToLower() <> "properties")
200
+
201
+ /// <summary>
202
+ /// Returns a sequence of all dynamic properties as a key value pair of the property names and the boxed property values.
203
+ ///
204
+ /// When includeInstanceProperties is set to true, instance properties (= 'static' properties on the class) are included in the result.
205
+ /// </summary>
206
+ /// <param name="includeInstanceProperties">whether to include instance properties (= 'static' properties on the class)</param>
207
+ member this.GetProperties includeInstanceProperties : seq<KeyValuePair<string,obj>> =
208
+ this.GetPropertyHelpers(includeInstanceProperties)
209
+ |> Seq.choose (fun kv ->
210
+ if kv.Name <> "properties" then
211
+ Some (KeyValuePair(kv.Name, kv.GetValue this))
212
+ else
213
+ None
214
+ )
215
+
216
+ /// <summary>
217
+ /// Returns a sequence of all dynamic property names.
218
+ ///
219
+ /// When includeInstanceProperties is set to true, instance properties (= 'static' properties on the class) are included in the result.
220
+ /// </summary>
221
+ /// <param name="includeInstanceProperties"></param>
222
+ member this.GetPropertyNames(includeInstanceProperties) =
223
+ this.GetProperties(includeInstanceProperties)
224
+ |> Seq.map (fun kv -> kv.Key)
225
+
226
+ /// <summary>
227
+ /// Copies all dynamic properties to a target `DynamicObj` instance without trying to prevent reference equality.
228
+ ///
229
+ /// Note that this function does not attempt to do any deep copying.
230
+ /// The dynamic properties of the source will be copied as references to the target.
231
+ /// If any of those properties are mutable or themselves DynamicObj instances, changes to the properties on the source will be reflected in the target.
232
+ ///
233
+ /// If overWrite is set to true, existing properties on the target object will be overwritten.
234
+ /// </summary>
235
+ /// <param name="target">The target object to copy dynamic members to</param>
236
+ /// <param name="overWrite">Whether existing properties on the target object will be overwritten</param>
237
+ member this.ShallowCopyDynamicPropertiesTo(target:#DynamicObj, ?overWrite) =
238
+ let overWrite = defaultArg overWrite false
239
+ this.GetProperties(false)
240
+ |> Seq.iter (fun kv ->
241
+ match target.TryGetPropertyHelper kv.Key with
242
+ | Some pi when overWrite -> pi.SetValue target kv.Value
243
+ | Some _ -> ()
244
+ | None -> target.SetProperty(kv.Key,kv.Value)
245
+ )
246
+
247
+ /// <summary>
248
+ /// Copies all dynamic properties to a new `DynamicObj` instance without trying to prevent reference equality.
249
+ ///
250
+ /// Note that this function does not attempt to do any deep copying.
251
+ /// The dynamic properties of the source will be copied as references to the target.
252
+ /// If any of those properties are mutable or themselves DynamicObj instances, changes to the properties on the source will be reflected in the target.
253
+ /// </summary>
254
+ member this.ShallowCopyDynamicProperties() =
255
+ let target = DynamicObj()
256
+ this.ShallowCopyDynamicPropertiesTo(target, true)
257
+ target
258
+
259
+ /// <summary>
260
+ /// Recursively deep copies **all** (static and dynamic) properties to a **target** `DynamicObj` instance (or derived class). Reinstantiation - and therefore prevention of reference equality - is possible for `DynamicObj`, `array|list|ResizeArray&lt;DynamicObj&gt;`, and classes implementing `System.Icloneable`
261
+ ///
262
+ /// As many properties as possible are re-instantiated as new objects, meaning the
263
+ /// copy has as little reference equal properties as possible.
264
+ ///
265
+ /// The nature of DynamicObj however means that it is impossible to reliably deep copy all properties, as
266
+ /// their type is not known on runtime and the contructors of the types are not known.
267
+ ///
268
+ /// The following cases are handled (in this precedence):
269
+ ///
270
+ /// - Basic F# types (`bool`, `byte`, `sbyte`, `int16`, `uint16`, `int`, `uint`, `int64`, `uint64`, `nativeint`, `unativeint`, `float`, `float32`, `char`, `string`, `unit`, `decimal`)
271
+ ///
272
+ /// - `ResizeArrays` and `Dictionaries` containing any combination of basic F# types
273
+ ///
274
+ /// - `Dictionaries` containing `DynamicObj` as keys or values in any combination with `DynamicObj` or basic F# types as keys or values
275
+ ///
276
+ /// - `array&lt;DynamicObj&gt;`, `list&lt;DynamicObj&gt;`, `ResizeArray&lt;DynamicObj&gt;`: These collections of DynamicObj are copied as a new collection with recursively deep copied elements.
277
+ ///
278
+ /// - `System.ICloneable`: If the property implements `ICloneable`, the `Clone()` method is called on the property.
279
+ ///
280
+ /// - `DynamicObj` (and derived classes): properties that are themselves `DynamicObj` instances are deep copied recursively.
281
+ /// if a derived class has static properties (e.g. instance properties), these can be copied as dynamic properties on the new instance or ignored.
282
+ ///
283
+ /// Note on Classes that inherit from `DynamicObj`:
284
+ ///
285
+ /// Classes that inherit from DynamicObj will match the `DynamicObj` typecheck if they do not implement `ICloneable`.
286
+ /// 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.
287
+ /// It should be possible to 'recover' the original type by checking if the needed properties exist as dynamic properties,
288
+ /// and then passing them to the class constructor if needed.
289
+ /// </summary>
290
+ /// <param name="target">The target object to copy dynamic members to</param>
291
+ /// <param name="overWrite">Whether existing properties on the target object will be overwritten. Default is false</param>
292
+ /// <param name="includeInstanceProperties">Whether to include instance properties (= 'static' properties on the class) as dynamic properties on the new instance. Default is true</param>
293
+ member this.DeepCopyPropertiesTo(
294
+ target:#DynamicObj,
295
+ ?overWrite: bool,
296
+ ?includeInstanceProperties:bool
297
+ ) =
298
+ let overWrite = defaultArg overWrite false
299
+ let includeInstanceProperties = defaultArg includeInstanceProperties true
300
+ this.GetProperties(includeInstanceProperties)
301
+ |> Seq.iter (fun kv ->
302
+ match target.TryGetPropertyHelper kv.Key with
303
+ | Some pi when overWrite -> pi.SetValue target (CopyUtils.tryDeepCopyObj kv.Value)
304
+ | Some _ -> ()
305
+ | None -> target.SetProperty(kv.Key, CopyUtils.tryDeepCopyObj kv.Value)
306
+ )
307
+
308
+ /// <summary>
309
+ /// Recursively deep copy a `DynamicObj` instance (or derived class) with **all** (static and dynamic) properties. Reinstantiation - and therefore prevention of reference equality - is possible for `DynamicObj`, `array|list|ResizeArray&lt;DynamicObj&gt;`, and classes implementing `System.Icloneable`
310
+ ///
311
+ /// On the deep copy, as many properties as possible are re-instantiated as new objects, meaning the
312
+ /// copy has as little reference equal properties as possible.
313
+ ///
314
+ /// The nature of DynamicObj however means that it is impossible to reliably deep copy all properties, as
315
+ /// their type is not known on runtime and the contructors of the types are not known.
316
+ ///
317
+ /// The following cases are handled (in this precedence):
318
+ ///
319
+ /// - Basic F# types (`bool`, `byte`, `sbyte`, `int16`, `uint16`, `int`, `uint`, `int64`, `uint64`, `nativeint`, `unativeint`, `float`, `float32`, `char`, `string`, `unit`, `decimal`)
320
+ ///
321
+ /// - `ResizeArrays` and `Dictionaries` containing any combination of basic F# types
322
+ ///
323
+ /// - `Dictionaries` containing `DynamicObj` as keys or values in any combination with `DynamicObj` or basic F# types as keys or values
324
+ ///
325
+ /// - `array&lt;DynamicObj&gt;`, `list&lt;DynamicObj&gt;`, `ResizeArray&lt;DynamicObj&gt;`: These collections of DynamicObj are copied as a new collection with recursively deep copied elements.
326
+ ///
327
+ /// - `System.ICloneable`: If the property implements `ICloneable`, the `Clone()` method is called on the property.
328
+ ///
329
+ /// - `DynamicObj` (and derived classes): properties that are themselves `DynamicObj` instances are deep copied recursively.
330
+ /// if a derived class has static properties (e.g. instance properties), these can be copied as dynamic properties on the new instance or ignored.
331
+ ///
332
+ /// Note on Classes that inherit from `DynamicObj`:
333
+ ///
334
+ /// Classes that inherit from DynamicObj will match the `DynamicObj` typecheck if they do not implement `ICloneable`.
335
+ /// 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.
336
+ /// It should be possible to 'recover' the original type by checking if the needed properties exist as dynamic properties,
337
+ /// and then passing them to the class constructor if needed.
338
+ /// </summary>
339
+ /// <param name="includeInstanceProperties">Whether to include instance properties (= 'static' properties on the class) as dynamic properties on the new instance. Default is true</param>
340
+ member this.DeepCopyProperties(?includeInstanceProperties:bool) =
341
+ let includeInstanceProperties = defaultArg includeInstanceProperties true
342
+ CopyUtils.tryDeepCopyObj(this, includeInstanceProperties)
343
+
344
+ #if !FABLE_COMPILER
345
+ // Some necessary overrides for methods inherited from System.Dynamic.DynamicObject()
346
+ //
347
+ // Needed mainly for making Newtonsoft.Json Serialization work
348
+ override this.TryGetMember(binder:GetMemberBinder,result:obj byref) =
349
+ match this.TryGetPropertyValue binder.Name with
350
+ | Some value -> result <- value; true
351
+ | None -> false
352
+
353
+ override this.TrySetMember(binder:SetMemberBinder, value:obj) =
354
+ this.SetProperty(binder.Name,value)
355
+ true
356
+
357
+ /// Returns both instance and dynamic member names.
358
+ /// Important to return both so JSON serialization with Json.NET works.
359
+ override this.GetDynamicMemberNames() = this.GetPropertyNames(true)
360
+
361
+ //// potential deserialization support
362
+ //[<JsonExtensionData>]
363
+ //member private this._additionalData : IDictionary<string, JToken> = new Dictionary<string, JToken>()
364
+
365
+ //[<OnDeserialized>]
366
+ //member private this.OnDeserialized(context:StreamingContext) = ()
367
+ // map over key value pairs in additional data, box the token values and set dynamic properties via SetProperty.
368
+
369
+ #endif
370
+
371
+ /// <summary>
372
+ /// Operator to access a property by name
373
+ ///
374
+ /// This method is not Fable-compatible and can therefore not be used in code that will be transpiled.
375
+ /// </summary>
376
+ /// <remarks>This method is not Fable-compatible and can therefore not be used in code that will be transpiled.</remarks>
377
+ static member (?) (lookup:#DynamicObj,name:string) =
378
+ match lookup.TryGetPropertyValue name with
379
+ | Some(value) -> value
380
+ | None -> raise <| System.MemberAccessException()
381
+
382
+ /// <summary>
383
+ /// Operator to set a property value
384
+ ///
385
+ /// This method is not Fable-compatible and can therefore not be used in code that will be transpiled.
386
+ /// </summary>
387
+ /// <remarks>This method is not Fable-compatible and can therefore not be used in code that will be transpiled.</remarks>
388
+ static member (?<-) (lookup:#DynamicObj,name:string,value:'v) =
389
+ lookup.SetProperty (name,value)
390
+
391
+ member this.ReferenceEquals (other: DynamicObj) = System.Object.ReferenceEquals(this,other)
392
+
393
+ member this.StructurallyEquals (other: DynamicObj) =
394
+ this.GetHashCode() = other.GetHashCode()
395
+
396
+ override this.GetHashCode () =
397
+ HashUtils.deepHash this
398
+
399
+ override this.Equals o =
400
+ match o with
401
+ | :? DynamicObj as other ->
402
+ this.StructurallyEquals(other)
403
+ | _ -> false
404
+
405
+ and HashUtils =
406
+
407
+ static member deepHash (o:obj) =
408
+ match o with
409
+ | :? DynamicObj as o ->
410
+ o.GetProperties(true)
411
+ |> Seq.sortBy (fun pair -> pair.Key)
412
+ |> HashCodes.boxHashKeyValSeqBy HashUtils.deepHash
413
+ |> fun x -> x :?> int
414
+ | :? string as s -> DynamicObj.HashCodes.hash s
415
+ #if !FABLE_COMPILER
416
+ | :? System.Collections.IDictionary as d ->
417
+ let mutable en = d.GetEnumerator()
418
+ [
419
+ while en.MoveNext() do
420
+ let c = en.Current :?> System.Collections.DictionaryEntry
421
+ HashCodes.mergeHashes (hash c.Key) (HashUtils.deepHash c.Value)
422
+ ]
423
+ |> fun l -> if l.IsEmpty then 0 else l |> List.reduce HashCodes.mergeHashes
424
+ #endif
425
+ | :? System.Collections.IEnumerable as e ->
426
+ let en = e.GetEnumerator()
427
+ [
428
+ while en.MoveNext() do
429
+ HashUtils.deepHash en.Current
430
+ ]
431
+ |> fun l -> if l.IsEmpty then 0 else l |> List.reduce HashCodes.mergeHashes
432
+ | _ -> DynamicObj.HashCodes.hash o
433
+
434
+ and CopyUtils =
435
+
436
+ /// <summary>
437
+ /// function to deep copy a boxed object (if possible)
438
+
439
+ /// The following cases are handled (in this precedence):
440
+ ///
441
+ /// - Basic F# types (`bool`, `byte`, `sbyte`, `int16`, `uint16`, `int`, `uint`, `int64`, `uint64`, `nativeint`, `unativeint`, `float`, `float32`, `char`, `string`, `unit`, `decimal`)
442
+ ///
443
+ /// - `ResizeArrays` and `Dictionaries` containing any combination of basic F# types
444
+ ///
445
+ /// - `Dictionaries` containing `DynamicObj` as keys or values in any combination with `DynamicObj` or basic F# types as keys or values
446
+ ///
447
+ /// - `array&lt;DynamicObj&gt;`, `list&lt;DynamicObj&gt;`, `ResizeArray&lt;DynamicObj&gt;`: These collections of DynamicObj are copied as a new collection with recursively deep copied elements.
448
+ ///
449
+ /// - `System.ICloneable`: If the property implements `ICloneable`, the `Clone()` method is called on the property.
450
+ ///
451
+ /// - `DynamicObj` (and derived classes): properties that are themselves `DynamicObj` instances are deep copied recursively.
452
+ /// if a derived class has static properties (e.g. instance properties), these can be copied as dynamic properties on the new instance or ignored.
453
+ ///
454
+ /// Note on Classes that inherit from `DynamicObj`:
455
+ ///
456
+ /// Classes that inherit from DynamicObj will match the `DynamicObj` typecheck if they do not implement `ICloneable`.
457
+ /// 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.
458
+ /// It should be possible to 'recover' the original type by checking if the needed properties exist as dynamic properties,
459
+ /// and then passing them to the class constructor if needed.
460
+ /// </summary>
461
+ /// <param name="o">The object that should be deep copied</param>
462
+ /// <param name="includeInstanceProperties">Whether to include instance properties (= 'static' properties on the class) as dynamic properties on the new instance for matched DynamicObj. Default is true</param>
463
+ static member tryDeepCopyObj(
464
+ o:obj,
465
+ ?includeInstanceProperties:bool
466
+ ) =
467
+ let includeInstanceProperties = defaultArg includeInstanceProperties true
468
+
469
+ let rec tryDeepCopyObj (o:obj) =
470
+ match o with
471
+
472
+ // might be that we do not need this case, however if we remove it, some types will match the
473
+ // ICloneable case in transpiled code, which we'd like to prevent, so well keep it for now.
474
+ // https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/basic-types
475
+ | :? bool
476
+ | :? byte
477
+ | :? sbyte
478
+ | :? int16
479
+ | :? uint16
480
+ | :? int
481
+ | :? uint
482
+ | :? int64
483
+ | :? uint64
484
+ #if !FABLE_COMPILER
485
+ | :? nativeint
486
+ | :? unativeint
487
+ #endif
488
+ | :? float
489
+ | :? float32
490
+ | :? char
491
+ | :? string
492
+ | :? unit
493
+ -> o
494
+
495
+ #if !FABLE_COMPILER_PYTHON
496
+ // https://github.com/fable-compiler/Fable/issues/3971
497
+ | :? decimal -> o
498
+ #endif
499
+
500
+ #if !FABLE_COMPILER
501
+
502
+ // we can do some more type checking in F# land
503
+
504
+ // ResizeArray typematches are all translated as `isArrayLike` in Fable JS/Py, so all these cases are the same in transpiled code.
505
+ // However this is fine, as we can transpile one single case (the `ResizeArray<DynamicObj>` case) that recursively applies `tryDeepCopyObj` on all items.
506
+ // That way, everything is fine in the untyped world, and we can keep the boxed types in F#.
507
+
508
+ // ResizeArrays are mutable and we need to copy them. For primitives, we can do this easily.
509
+ | :? ResizeArray<bool> as r -> ResizeArray(r) |> box
510
+ | :? ResizeArray<byte> as r -> ResizeArray(r) |> box
511
+ | :? ResizeArray<sbyte> as r -> ResizeArray(r) |> box
512
+ | :? ResizeArray<int16> as r -> ResizeArray(r) |> box
513
+ | :? ResizeArray<uint16> as r -> ResizeArray(r) |> box
514
+ | :? ResizeArray<int> as r -> ResizeArray(r) |> box
515
+ | :? ResizeArray<uint> as r -> ResizeArray(r) |> box
516
+ | :? ResizeArray<int64> as r -> ResizeArray(r) |> box
517
+ | :? ResizeArray<uint64> as r -> ResizeArray(r) |> box
518
+ | :? ResizeArray<nativeint> as r -> ResizeArray(r) |> box
519
+ | :? ResizeArray<unativeint> as r -> ResizeArray(r) |> box
520
+ | :? ResizeArray<float> as r -> ResizeArray(r) |> box
521
+ | :? ResizeArray<float32> as r -> ResizeArray(r) |> box
522
+ | :? ResizeArray<char> as r -> ResizeArray(r) |> box
523
+ | :? ResizeArray<string> as r -> ResizeArray(r) |> box
524
+ | :? ResizeArray<unit> as r -> ResizeArray(r) |> box
525
+ | :? ResizeArray<decimal> as r -> ResizeArray(r) |> box
526
+
527
+ // Dictionaries are mutable and we need to copy them. For primitives, we can do this easily, it is just a lot of work to write man
528
+ // Fable does simply not compile these typechecks, i guess because everything is an object/dictionary in JS/PY.
529
+ | :? Dictionary<bool,bool> as dict -> Dictionary<bool,bool>(dict) |> box
530
+ | :? Dictionary<bool,byte> as dict -> Dictionary<bool,byte>(dict) |> box
531
+ | :? Dictionary<bool,sbyte> as dict -> Dictionary<bool,sbyte>(dict) |> box
532
+ | :? Dictionary<bool,int16> as dict -> Dictionary<bool,int16>(dict) |> box
533
+ | :? Dictionary<bool,uint16> as dict -> Dictionary<bool,uint16>(dict) |> box
534
+ | :? Dictionary<bool,int> as dict -> Dictionary<bool,int>(dict) |> box
535
+ | :? Dictionary<bool,uint> as dict -> Dictionary<bool,uint>(dict) |> box
536
+ | :? Dictionary<bool,int64> as dict -> Dictionary<bool,int64>(dict) |> box
537
+ | :? Dictionary<bool,uint64> as dict -> Dictionary<bool,uint64>(dict) |> box
538
+ | :? Dictionary<bool,nativeint> as dict -> Dictionary<bool,nativeint>(dict) |> box
539
+ | :? Dictionary<bool,unativeint> as dict -> Dictionary<bool,unativeint>(dict) |> box
540
+ | :? Dictionary<bool,float> as dict -> Dictionary<bool,float>(dict) |> box
541
+ | :? Dictionary<bool,float32> as dict -> Dictionary<bool,float32>(dict) |> box
542
+ | :? Dictionary<bool,char> as dict -> Dictionary<bool,char>(dict) |> box
543
+ | :? Dictionary<bool,string> as dict -> Dictionary<bool,string>(dict) |> box
544
+ | :? Dictionary<bool,unit> as dict -> Dictionary<bool,unit>(dict) |> box
545
+ | :? Dictionary<bool,decimal> as dict -> Dictionary<bool,decimal>(dict) |> box
546
+
547
+ | :? Dictionary<byte,bool> as dict -> Dictionary<byte,bool>(dict) |> box
548
+ | :? Dictionary<byte,byte> as dict -> Dictionary<byte,byte>(dict) |> box
549
+ | :? Dictionary<byte,sbyte> as dict -> Dictionary<byte,sbyte>(dict) |> box
550
+ | :? Dictionary<byte,int16> as dict -> Dictionary<byte,int16>(dict) |> box
551
+ | :? Dictionary<byte,uint16> as dict -> Dictionary<byte,uint16>(dict) |> box
552
+ | :? Dictionary<byte,int> as dict -> Dictionary<byte,int>(dict) |> box
553
+ | :? Dictionary<byte,uint> as dict -> Dictionary<byte,uint>(dict) |> box
554
+ | :? Dictionary<byte,int64> as dict -> Dictionary<byte,int64>(dict) |> box
555
+ | :? Dictionary<byte,uint64> as dict -> Dictionary<byte,uint64>(dict) |> box
556
+ | :? Dictionary<byte,nativeint> as dict -> Dictionary<byte,nativeint>(dict) |> box
557
+ | :? Dictionary<byte,unativeint> as dict -> Dictionary<byte,unativeint>(dict) |> box
558
+ | :? Dictionary<byte,float> as dict -> Dictionary<byte,float>(dict) |> box
559
+ | :? Dictionary<byte,float32> as dict -> Dictionary<byte,float32>(dict) |> box
560
+ | :? Dictionary<byte,char> as dict -> Dictionary<byte,char>(dict) |> box
561
+ | :? Dictionary<byte,string> as dict -> Dictionary<byte,string>(dict) |> box
562
+ | :? Dictionary<byte,unit> as dict -> Dictionary<byte,unit>(dict) |> box
563
+ | :? Dictionary<byte,decimal> as dict -> Dictionary<byte,decimal>(dict) |> box
564
+
565
+ | :? Dictionary<sbyte,bool> as dict -> Dictionary<sbyte,bool>(dict) |> box
566
+ | :? Dictionary<sbyte,byte> as dict -> Dictionary<sbyte,byte>(dict) |> box
567
+ | :? Dictionary<sbyte,sbyte> as dict -> Dictionary<sbyte,sbyte>(dict) |> box
568
+ | :? Dictionary<sbyte,int16> as dict -> Dictionary<sbyte,int16>(dict) |> box
569
+ | :? Dictionary<sbyte,uint16> as dict -> Dictionary<sbyte,uint16>(dict) |> box
570
+ | :? Dictionary<sbyte,int> as dict -> Dictionary<sbyte,int>(dict) |> box
571
+ | :? Dictionary<sbyte,uint> as dict -> Dictionary<sbyte,uint>(dict) |> box
572
+ | :? Dictionary<sbyte,int64> as dict -> Dictionary<sbyte,int64>(dict) |> box
573
+ | :? Dictionary<sbyte,uint64> as dict -> Dictionary<sbyte,uint64>(dict) |> box
574
+ | :? Dictionary<sbyte,nativeint> as dict -> Dictionary<sbyte,nativeint>(dict) |> box
575
+ | :? Dictionary<sbyte,unativeint> as dict -> Dictionary<sbyte,unativeint>(dict) |> box
576
+ | :? Dictionary<sbyte,float> as dict -> Dictionary<sbyte,float>(dict) |> box
577
+ | :? Dictionary<sbyte,float32> as dict -> Dictionary<sbyte,float32>(dict) |> box
578
+ | :? Dictionary<sbyte,char> as dict -> Dictionary<sbyte,char>(dict) |> box
579
+ | :? Dictionary<sbyte,string> as dict -> Dictionary<sbyte,string>(dict) |> box
580
+ | :? Dictionary<sbyte,unit> as dict -> Dictionary<sbyte,unit>(dict) |> box
581
+ | :? Dictionary<sbyte,decimal> as dict -> Dictionary<sbyte,decimal>(dict) |> box
582
+
583
+ | :? Dictionary<int16,bool> as dict -> Dictionary<int16,bool>(dict) |> box
584
+ | :? Dictionary<int16,byte> as dict -> Dictionary<int16,byte>(dict) |> box
585
+ | :? Dictionary<int16,sbyte> as dict -> Dictionary<int16,sbyte>(dict) |> box
586
+ | :? Dictionary<int16,int16> as dict -> Dictionary<int16,int16>(dict) |> box
587
+ | :? Dictionary<int16,uint16> as dict -> Dictionary<int16,uint16>(dict) |> box
588
+ | :? Dictionary<int16,int> as dict -> Dictionary<int16,int>(dict) |> box
589
+ | :? Dictionary<int16,uint> as dict -> Dictionary<int16,uint>(dict) |> box
590
+ | :? Dictionary<int16,int64> as dict -> Dictionary<int16,int64>(dict) |> box
591
+ | :? Dictionary<int16,uint64> as dict -> Dictionary<int16,uint64>(dict) |> box
592
+ | :? Dictionary<int16,nativeint> as dict -> Dictionary<int16,nativeint>(dict) |> box
593
+ | :? Dictionary<int16,unativeint> as dict -> Dictionary<int16,unativeint>(dict) |> box
594
+ | :? Dictionary<int16,float> as dict -> Dictionary<int16,float>(dict) |> box
595
+ | :? Dictionary<int16,float32> as dict -> Dictionary<int16,float32>(dict) |> box
596
+ | :? Dictionary<int16,char> as dict -> Dictionary<int16,char>(dict) |> box
597
+ | :? Dictionary<int16,string> as dict -> Dictionary<int16,string>(dict) |> box
598
+ | :? Dictionary<int16,unit> as dict -> Dictionary<int16,unit>(dict) |> box
599
+ | :? Dictionary<int16,decimal> as dict -> Dictionary<int16,decimal>(dict) |> box
600
+
601
+ | :? Dictionary<uint16,bool> as dict -> Dictionary<uint16,bool>(dict) |> box
602
+ | :? Dictionary<uint16,byte> as dict -> Dictionary<uint16,byte>(dict) |> box
603
+ | :? Dictionary<uint16,sbyte> as dict -> Dictionary<uint16,sbyte>(dict) |> box
604
+ | :? Dictionary<uint16,int16> as dict -> Dictionary<uint16,int16>(dict) |> box
605
+ | :? Dictionary<uint16,uint16> as dict -> Dictionary<uint16,uint16>(dict) |> box
606
+ | :? Dictionary<uint16,int> as dict -> Dictionary<uint16,int>(dict) |> box
607
+ | :? Dictionary<uint16,uint> as dict -> Dictionary<uint16,uint>(dict) |> box
608
+ | :? Dictionary<uint16,int64> as dict -> Dictionary<uint16,int64>(dict) |> box
609
+ | :? Dictionary<uint16,uint64> as dict -> Dictionary<uint16,uint64>(dict) |> box
610
+ | :? Dictionary<uint16,nativeint> as dict -> Dictionary<uint16,nativeint>(dict) |> box
611
+ | :? Dictionary<uint16,unativeint> as dict -> Dictionary<uint16,unativeint>(dict) |> box
612
+ | :? Dictionary<uint16,float> as dict -> Dictionary<uint16,float>(dict) |> box
613
+ | :? Dictionary<uint16,float32> as dict -> Dictionary<uint16,float32>(dict) |> box
614
+ | :? Dictionary<uint16,char> as dict -> Dictionary<uint16,char>(dict) |> box
615
+ | :? Dictionary<uint16,string> as dict -> Dictionary<uint16,string>(dict) |> box
616
+ | :? Dictionary<uint16,unit> as dict -> Dictionary<uint16,unit>(dict) |> box
617
+ | :? Dictionary<uint16,decimal> as dict -> Dictionary<uint16,decimal>(dict) |> box
618
+
619
+ | :? Dictionary<int,bool> as dict -> Dictionary<int,bool>(dict) |> box
620
+ | :? Dictionary<int,byte> as dict -> Dictionary<int,byte>(dict) |> box
621
+ | :? Dictionary<int,sbyte> as dict -> Dictionary<int,sbyte>(dict) |> box
622
+ | :? Dictionary<int,int16> as dict -> Dictionary<int,int16>(dict) |> box
623
+ | :? Dictionary<int,uint16> as dict -> Dictionary<int,uint16>(dict) |> box
624
+ | :? Dictionary<int,int> as dict -> Dictionary<int,int>(dict) |> box
625
+ | :? Dictionary<int,uint> as dict -> Dictionary<int,uint>(dict) |> box
626
+ | :? Dictionary<int,int64> as dict -> Dictionary<int,int64>(dict) |> box
627
+ | :? Dictionary<int,uint64> as dict -> Dictionary<int,uint64>(dict) |> box
628
+ | :? Dictionary<int,nativeint> as dict -> Dictionary<int,nativeint>(dict) |> box
629
+ | :? Dictionary<int,unativeint> as dict -> Dictionary<int,unativeint>(dict) |> box
630
+ | :? Dictionary<int,float> as dict -> Dictionary<int,float>(dict) |> box
631
+ | :? Dictionary<int,float32> as dict -> Dictionary<int,float32>(dict) |> box
632
+ | :? Dictionary<int,char> as dict -> Dictionary<int,char>(dict) |> box
633
+ | :? Dictionary<int,string> as dict -> Dictionary<int,string>(dict) |> box
634
+ | :? Dictionary<int,unit> as dict -> Dictionary<int,unit>(dict) |> box
635
+ | :? Dictionary<int,decimal> as dict -> Dictionary<int,decimal>(dict) |> box
636
+
637
+ | :? Dictionary<uint,bool> as dict -> Dictionary<uint,bool>(dict) |> box
638
+ | :? Dictionary<uint,byte> as dict -> Dictionary<uint,byte>(dict) |> box
639
+ | :? Dictionary<uint,sbyte> as dict -> Dictionary<uint,sbyte>(dict) |> box
640
+ | :? Dictionary<uint,int16> as dict -> Dictionary<uint,int16>(dict) |> box
641
+ | :? Dictionary<uint,uint16> as dict -> Dictionary<uint,uint16>(dict) |> box
642
+ | :? Dictionary<uint,int> as dict -> Dictionary<uint,int>(dict) |> box
643
+ | :? Dictionary<uint,uint> as dict -> Dictionary<uint,uint>(dict) |> box
644
+ | :? Dictionary<uint,int64> as dict -> Dictionary<uint,int64>(dict) |> box
645
+ | :? Dictionary<uint,uint64> as dict -> Dictionary<uint,uint64>(dict) |> box
646
+ | :? Dictionary<uint,nativeint> as dict -> Dictionary<uint,nativeint>(dict) |> box
647
+ | :? Dictionary<uint,unativeint> as dict -> Dictionary<uint,unativeint>(dict) |> box
648
+ | :? Dictionary<uint,float> as dict -> Dictionary<uint,float>(dict) |> box
649
+ | :? Dictionary<uint,float32> as dict -> Dictionary<uint,float32>(dict) |> box
650
+ | :? Dictionary<uint,char> as dict -> Dictionary<uint,char>(dict) |> box
651
+ | :? Dictionary<uint,string> as dict -> Dictionary<uint,string>(dict) |> box
652
+ | :? Dictionary<uint,unit> as dict -> Dictionary<uint,unit>(dict) |> box
653
+ | :? Dictionary<uint,decimal> as dict -> Dictionary<uint,decimal>(dict) |> box
654
+
655
+ | :? Dictionary<int64,bool> as dict -> Dictionary<int64,bool>(dict) |> box
656
+ | :? Dictionary<int64,byte> as dict -> Dictionary<int64,byte>(dict) |> box
657
+ | :? Dictionary<int64,sbyte> as dict -> Dictionary<int64,sbyte>(dict) |> box
658
+ | :? Dictionary<int64,int16> as dict -> Dictionary<int64,int16>(dict) |> box
659
+ | :? Dictionary<int64,uint16> as dict -> Dictionary<int64,uint16>(dict) |> box
660
+ | :? Dictionary<int64,int> as dict -> Dictionary<int64,int>(dict) |> box
661
+ | :? Dictionary<int64,uint> as dict -> Dictionary<int64,uint>(dict) |> box
662
+ | :? Dictionary<int64,int64> as dict -> Dictionary<int64,int64>(dict) |> box
663
+ | :? Dictionary<int64,uint64> as dict -> Dictionary<int64,uint64>(dict) |> box
664
+ | :? Dictionary<int64,nativeint> as dict -> Dictionary<int64,nativeint>(dict) |> box
665
+ | :? Dictionary<int64,unativeint> as dict -> Dictionary<int64,unativeint>(dict) |> box
666
+ | :? Dictionary<int64,float> as dict -> Dictionary<int64,float>(dict) |> box
667
+ | :? Dictionary<int64,float32> as dict -> Dictionary<int64,float32>(dict) |> box
668
+ | :? Dictionary<int64,char> as dict -> Dictionary<int64,char>(dict) |> box
669
+ | :? Dictionary<int64,string> as dict -> Dictionary<int64,string>(dict) |> box
670
+ | :? Dictionary<int64,unit> as dict -> Dictionary<int64,unit>(dict) |> box
671
+ | :? Dictionary<int64,decimal> as dict -> Dictionary<int64,decimal>(dict) |> box
672
+
673
+ | :? Dictionary<uint64,bool> as dict -> Dictionary<uint64,bool>(dict) |> box
674
+ | :? Dictionary<uint64,byte> as dict -> Dictionary<uint64,byte>(dict) |> box
675
+ | :? Dictionary<uint64,sbyte> as dict -> Dictionary<uint64,sbyte>(dict) |> box
676
+ | :? Dictionary<uint64,int16> as dict -> Dictionary<uint64,int16>(dict) |> box
677
+ | :? Dictionary<uint64,uint16> as dict -> Dictionary<uint64,uint16>(dict) |> box
678
+ | :? Dictionary<uint64,int> as dict -> Dictionary<uint64,int>(dict) |> box
679
+ | :? Dictionary<uint64,uint> as dict -> Dictionary<uint64,uint>(dict) |> box
680
+ | :? Dictionary<uint64,int64> as dict -> Dictionary<uint64,int64>(dict) |> box
681
+ | :? Dictionary<uint64,uint64> as dict -> Dictionary<uint64,uint64>(dict) |> box
682
+ | :? Dictionary<uint64,nativeint> as dict -> Dictionary<uint64,nativeint>(dict) |> box
683
+ | :? Dictionary<uint64,unativeint> as dict -> Dictionary<uint64,unativeint>(dict) |> box
684
+ | :? Dictionary<uint64,float> as dict -> Dictionary<uint64,float>(dict) |> box
685
+ | :? Dictionary<uint64,float32> as dict -> Dictionary<uint64,float32>(dict) |> box
686
+ | :? Dictionary<uint64,char> as dict -> Dictionary<uint64,char>(dict) |> box
687
+ | :? Dictionary<uint64,string> as dict -> Dictionary<uint64,string>(dict) |> box
688
+ | :? Dictionary<uint64,unit> as dict -> Dictionary<uint64,unit>(dict) |> box
689
+ | :? Dictionary<uint64,decimal> as dict -> Dictionary<uint64,decimal>(dict) |> box
690
+
691
+ | :? Dictionary<nativeint,bool> as dict -> Dictionary<nativeint,bool>(dict) |> box
692
+ | :? Dictionary<nativeint,byte> as dict -> Dictionary<nativeint,byte>(dict) |> box
693
+ | :? Dictionary<nativeint,sbyte> as dict -> Dictionary<nativeint,sbyte>(dict) |> box
694
+ | :? Dictionary<nativeint,int16> as dict -> Dictionary<nativeint,int16>(dict) |> box
695
+ | :? Dictionary<nativeint,uint16> as dict -> Dictionary<nativeint,uint16>(dict) |> box
696
+ | :? Dictionary<nativeint,int> as dict -> Dictionary<nativeint,int>(dict) |> box
697
+ | :? Dictionary<nativeint,uint> as dict -> Dictionary<nativeint,uint>(dict) |> box
698
+ | :? Dictionary<nativeint,int64> as dict -> Dictionary<nativeint,int64>(dict) |> box
699
+ | :? Dictionary<nativeint,uint64> as dict -> Dictionary<nativeint,uint64>(dict) |> box
700
+ | :? Dictionary<nativeint,nativeint> as dict -> Dictionary<nativeint,nativeint>(dict) |> box
701
+ | :? Dictionary<nativeint,unativeint> as dict -> Dictionary<nativeint,unativeint>(dict) |> box
702
+ | :? Dictionary<nativeint,float> as dict -> Dictionary<nativeint,float>(dict) |> box
703
+ | :? Dictionary<nativeint,float32> as dict -> Dictionary<nativeint,float32>(dict) |> box
704
+ | :? Dictionary<nativeint,char> as dict -> Dictionary<nativeint,char>(dict) |> box
705
+ | :? Dictionary<nativeint,string> as dict -> Dictionary<nativeint,string>(dict) |> box
706
+ | :? Dictionary<nativeint,unit> as dict -> Dictionary<nativeint,unit>(dict) |> box
707
+ | :? Dictionary<nativeint,decimal> as dict -> Dictionary<nativeint,decimal>(dict) |> box
708
+
709
+ | :? Dictionary<unativeint,bool> as dict -> Dictionary<unativeint,bool>(dict) |> box
710
+ | :? Dictionary<unativeint,byte> as dict -> Dictionary<unativeint,byte>(dict) |> box
711
+ | :? Dictionary<unativeint,sbyte> as dict -> Dictionary<unativeint,sbyte>(dict) |> box
712
+ | :? Dictionary<unativeint,int16> as dict -> Dictionary<unativeint,int16>(dict) |> box
713
+ | :? Dictionary<unativeint,uint16> as dict -> Dictionary<unativeint,uint16>(dict) |> box
714
+ | :? Dictionary<unativeint,int> as dict -> Dictionary<unativeint,int>(dict) |> box
715
+ | :? Dictionary<unativeint,uint> as dict -> Dictionary<unativeint,uint>(dict) |> box
716
+ | :? Dictionary<unativeint,int64> as dict -> Dictionary<unativeint,int64>(dict) |> box
717
+ | :? Dictionary<unativeint,uint64> as dict -> Dictionary<unativeint,uint64>(dict) |> box
718
+ | :? Dictionary<unativeint,nativeint> as dict -> Dictionary<unativeint,nativeint>(dict) |> box
719
+ | :? Dictionary<unativeint,unativeint> as dict -> Dictionary<unativeint,unativeint>(dict) |> box
720
+ | :? Dictionary<unativeint,float> as dict -> Dictionary<unativeint,float>(dict) |> box
721
+ | :? Dictionary<unativeint,float32> as dict -> Dictionary<unativeint,float32>(dict) |> box
722
+ | :? Dictionary<unativeint,char> as dict -> Dictionary<unativeint,char>(dict) |> box
723
+ | :? Dictionary<unativeint,string> as dict -> Dictionary<unativeint,string>(dict) |> box
724
+ | :? Dictionary<unativeint,unit> as dict -> Dictionary<unativeint,unit>(dict) |> box
725
+ | :? Dictionary<unativeint,decimal> as dict -> Dictionary<unativeint,decimal>(dict) |> box
726
+
727
+ | :? Dictionary<float,bool> as dict -> Dictionary<float,bool>(dict) |> box
728
+ | :? Dictionary<float,byte> as dict -> Dictionary<float,byte>(dict) |> box
729
+ | :? Dictionary<float,sbyte> as dict -> Dictionary<float,sbyte>(dict) |> box
730
+ | :? Dictionary<float,int16> as dict -> Dictionary<float,int16>(dict) |> box
731
+ | :? Dictionary<float,uint16> as dict -> Dictionary<float,uint16>(dict) |> box
732
+ | :? Dictionary<float,int> as dict -> Dictionary<float,int>(dict) |> box
733
+ | :? Dictionary<float,uint> as dict -> Dictionary<float,uint>(dict) |> box
734
+ | :? Dictionary<float,int64> as dict -> Dictionary<float,int64>(dict) |> box
735
+ | :? Dictionary<float,uint64> as dict -> Dictionary<float,uint64>(dict) |> box
736
+ | :? Dictionary<float,nativeint> as dict -> Dictionary<float,nativeint>(dict) |> box
737
+ | :? Dictionary<float,unativeint> as dict -> Dictionary<float,unativeint>(dict) |> box
738
+ | :? Dictionary<float,float> as dict -> Dictionary<float,float>(dict) |> box
739
+ | :? Dictionary<float,float32> as dict -> Dictionary<float,float32>(dict) |> box
740
+ | :? Dictionary<float,char> as dict -> Dictionary<float,char>(dict) |> box
741
+ | :? Dictionary<float,string> as dict -> Dictionary<float,string>(dict) |> box
742
+ | :? Dictionary<float,unit> as dict -> Dictionary<float,unit>(dict) |> box
743
+ | :? Dictionary<float,decimal> as dict -> Dictionary<float,decimal>(dict) |> box
744
+
745
+ | :? Dictionary<float32,bool> as dict -> Dictionary<float32,bool>(dict) |> box
746
+ | :? Dictionary<float32,byte> as dict -> Dictionary<float32,byte>(dict) |> box
747
+ | :? Dictionary<float32,sbyte> as dict -> Dictionary<float32,sbyte>(dict) |> box
748
+ | :? Dictionary<float32,int16> as dict -> Dictionary<float32,int16>(dict) |> box
749
+ | :? Dictionary<float32,uint16> as dict -> Dictionary<float32,uint16>(dict) |> box
750
+ | :? Dictionary<float32,int> as dict -> Dictionary<float32,int>(dict) |> box
751
+ | :? Dictionary<float32,uint> as dict -> Dictionary<float32,uint>(dict) |> box
752
+ | :? Dictionary<float32,int64> as dict -> Dictionary<float32,int64>(dict) |> box
753
+ | :? Dictionary<float32,uint64> as dict -> Dictionary<float32,uint64>(dict) |> box
754
+ | :? Dictionary<float32,nativeint> as dict -> Dictionary<float32,nativeint>(dict) |> box
755
+ | :? Dictionary<float32,unativeint> as dict -> Dictionary<float32,unativeint>(dict) |> box
756
+ | :? Dictionary<float32,float> as dict -> Dictionary<float32,float>(dict) |> box
757
+ | :? Dictionary<float32,float32> as dict -> Dictionary<float32,float32>(dict) |> box
758
+ | :? Dictionary<float32,char> as dict -> Dictionary<float32,char>(dict) |> box
759
+ | :? Dictionary<float32,string> as dict -> Dictionary<float32,string>(dict) |> box
760
+ | :? Dictionary<float32,unit> as dict -> Dictionary<float32,unit>(dict) |> box
761
+ | :? Dictionary<float32,decimal> as dict -> Dictionary<float32,decimal>(dict) |> box
762
+
763
+ | :? Dictionary<char,bool> as dict -> Dictionary<char,bool>(dict) |> box
764
+ | :? Dictionary<char,byte> as dict -> Dictionary<char,byte>(dict) |> box
765
+ | :? Dictionary<char,sbyte> as dict -> Dictionary<char,sbyte>(dict) |> box
766
+ | :? Dictionary<char,int16> as dict -> Dictionary<char,int16>(dict) |> box
767
+ | :? Dictionary<char,uint16> as dict -> Dictionary<char,uint16>(dict) |> box
768
+ | :? Dictionary<char,int> as dict -> Dictionary<char,int>(dict) |> box
769
+ | :? Dictionary<char,uint> as dict -> Dictionary<char,uint>(dict) |> box
770
+ | :? Dictionary<char,int64> as dict -> Dictionary<char,int64>(dict) |> box
771
+ | :? Dictionary<char,uint64> as dict -> Dictionary<char,uint64>(dict) |> box
772
+ | :? Dictionary<char,nativeint> as dict -> Dictionary<char,nativeint>(dict) |> box
773
+ | :? Dictionary<char,unativeint> as dict -> Dictionary<char,unativeint>(dict) |> box
774
+ | :? Dictionary<char,float> as dict -> Dictionary<char,float>(dict) |> box
775
+ | :? Dictionary<char,float32> as dict -> Dictionary<char,float32>(dict) |> box
776
+ | :? Dictionary<char,char> as dict -> Dictionary<char,char>(dict) |> box
777
+ | :? Dictionary<char,string> as dict -> Dictionary<char,string>(dict) |> box
778
+ | :? Dictionary<char,unit> as dict -> Dictionary<char,unit>(dict) |> box
779
+ | :? Dictionary<char,decimal> as dict -> Dictionary<char,decimal>(dict) |> box
780
+
781
+ | :? Dictionary<string,bool> as dict -> Dictionary<string,bool>(dict) |> box
782
+ | :? Dictionary<string,byte> as dict -> Dictionary<string,byte>(dict) |> box
783
+ | :? Dictionary<string,sbyte> as dict -> Dictionary<string,sbyte>(dict) |> box
784
+ | :? Dictionary<string,int16> as dict -> Dictionary<string,int16>(dict) |> box
785
+ | :? Dictionary<string,uint16> as dict -> Dictionary<string,uint16>(dict) |> box
786
+ | :? Dictionary<string,int> as dict -> Dictionary<string,int>(dict) |> box
787
+ | :? Dictionary<string,uint> as dict -> Dictionary<string,uint>(dict) |> box
788
+ | :? Dictionary<string,int64> as dict -> Dictionary<string,int64>(dict) |> box
789
+ | :? Dictionary<string,uint64> as dict -> Dictionary<string,uint64>(dict) |> box
790
+ | :? Dictionary<string,nativeint> as dict -> Dictionary<string,nativeint>(dict) |> box
791
+ | :? Dictionary<string,unativeint> as dict -> Dictionary<string,unativeint>(dict) |> box
792
+ | :? Dictionary<string,float> as dict -> Dictionary<string,float>(dict) |> box
793
+ | :? Dictionary<string,float32> as dict -> Dictionary<string,float32>(dict) |> box
794
+ | :? Dictionary<string,char> as dict -> Dictionary<string,char>(dict) |> box
795
+ | :? Dictionary<string,string> as dict -> Dictionary<string,string>(dict) |> box
796
+ | :? Dictionary<string,unit> as dict -> Dictionary<string,unit>(dict) |> box
797
+ | :? Dictionary<string,decimal> as dict -> Dictionary<string,decimal>(dict) |> box
798
+
799
+ | :? Dictionary<unit,bool> as dict -> Dictionary<unit,bool>(dict) |> box
800
+ | :? Dictionary<unit,byte> as dict -> Dictionary<unit,byte>(dict) |> box
801
+ | :? Dictionary<unit,sbyte> as dict -> Dictionary<unit,sbyte>(dict) |> box
802
+ | :? Dictionary<unit,int16> as dict -> Dictionary<unit,int16>(dict) |> box
803
+ | :? Dictionary<unit,uint16> as dict -> Dictionary<unit,uint16>(dict) |> box
804
+ | :? Dictionary<unit,int> as dict -> Dictionary<unit,int>(dict) |> box
805
+ | :? Dictionary<unit,uint> as dict -> Dictionary<unit,uint>(dict) |> box
806
+ | :? Dictionary<unit,int64> as dict -> Dictionary<unit,int64>(dict) |> box
807
+ | :? Dictionary<unit,uint64> as dict -> Dictionary<unit,uint64>(dict) |> box
808
+ | :? Dictionary<unit,nativeint> as dict -> Dictionary<unit,nativeint>(dict) |> box
809
+ | :? Dictionary<unit,unativeint> as dict -> Dictionary<unit,unativeint>(dict) |> box
810
+ | :? Dictionary<unit,float> as dict -> Dictionary<unit,float>(dict) |> box
811
+ | :? Dictionary<unit,float32> as dict -> Dictionary<unit,float32>(dict) |> box
812
+ | :? Dictionary<unit,char> as dict -> Dictionary<unit,char>(dict) |> box
813
+ | :? Dictionary<unit,string> as dict -> Dictionary<unit,string>(dict) |> box
814
+ | :? Dictionary<unit,unit> as dict -> Dictionary<unit,unit>(dict) |> box
815
+ | :? Dictionary<unit,decimal> as dict -> Dictionary<unit,decimal>(dict) |> box
816
+
817
+ | :? Dictionary<decimal,bool> as dict -> Dictionary<decimal,bool>(dict) |> box
818
+ | :? Dictionary<decimal,byte> as dict -> Dictionary<decimal,byte>(dict) |> box
819
+ | :? Dictionary<decimal,sbyte> as dict -> Dictionary<decimal,sbyte>(dict) |> box
820
+ | :? Dictionary<decimal,int16> as dict -> Dictionary<decimal,int16>(dict) |> box
821
+ | :? Dictionary<decimal,uint16> as dict -> Dictionary<decimal,uint16>(dict) |> box
822
+ | :? Dictionary<decimal,int> as dict -> Dictionary<decimal,int>(dict) |> box
823
+ | :? Dictionary<decimal,uint> as dict -> Dictionary<decimal,uint>(dict) |> box
824
+ | :? Dictionary<decimal,int64> as dict -> Dictionary<decimal,int64>(dict) |> box
825
+ | :? Dictionary<decimal,uint64> as dict -> Dictionary<decimal,uint64>(dict) |> box
826
+ | :? Dictionary<decimal,nativeint> as dict -> Dictionary<decimal,nativeint>(dict) |> box
827
+ | :? Dictionary<decimal,unativeint> as dict -> Dictionary<decimal,unativeint>(dict) |> box
828
+ | :? Dictionary<decimal,float> as dict -> Dictionary<decimal,float>(dict) |> box
829
+ | :? Dictionary<decimal,float32> as dict -> Dictionary<decimal,float32>(dict) |> box
830
+ | :? Dictionary<decimal,char> as dict -> Dictionary<decimal,char>(dict) |> box
831
+ | :? Dictionary<decimal,string> as dict -> Dictionary<decimal,string>(dict) |> box
832
+ | :? Dictionary<decimal,unit> as dict -> Dictionary<decimal,unit>(dict) |> box
833
+ | :? Dictionary<decimal,decimal> as dict -> Dictionary<decimal,decimal>(dict) |> box
834
+
835
+ // same for dictionaries containing DynamicObj as value
836
+ | :? Dictionary<bool,DynamicObj> as dict ->
837
+ let newDict = Dictionary<bool,DynamicObj>()
838
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
839
+ newDict |> box
840
+ | :? Dictionary<byte,DynamicObj> as dict ->
841
+ let newDict = Dictionary<byte,DynamicObj>()
842
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
843
+ newDict |> box
844
+ | :? Dictionary<sbyte ,DynamicObj> as dict ->
845
+ let newDict = Dictionary<sbyte ,DynamicObj>()
846
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
847
+ newDict |> box
848
+ | :? Dictionary<int16,DynamicObj> as dict ->
849
+ let newDict = Dictionary<int16,DynamicObj>()
850
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
851
+ newDict |> box
852
+ | :? Dictionary<uint16,DynamicObj> as dict ->
853
+ let newDict = Dictionary<uint16,DynamicObj>()
854
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
855
+ newDict |> box
856
+ | :? Dictionary<int,DynamicObj> as dict ->
857
+ let newDict = Dictionary<int,DynamicObj>()
858
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
859
+ newDict |> box
860
+ | :? Dictionary<uint,DynamicObj> as dict ->
861
+ let newDict = Dictionary<uint,DynamicObj>()
862
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
863
+ newDict |> box
864
+ | :? Dictionary<int64,DynamicObj> as dict ->
865
+ let newDict = Dictionary<int64,DynamicObj>()
866
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
867
+ newDict |> box
868
+ | :? Dictionary<uint64,DynamicObj> as dict ->
869
+ let newDict = Dictionary<uint64,DynamicObj>()
870
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
871
+ newDict |> box
872
+ | :? Dictionary<nativeint,DynamicObj> as dict ->
873
+ let newDict = Dictionary<nativeint,DynamicObj>()
874
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
875
+ newDict |> box
876
+ | :? Dictionary<unativeint,DynamicObj> as dict ->
877
+ let newDict = Dictionary<unativeint,DynamicObj>()
878
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
879
+ newDict |> box
880
+ | :? Dictionary<float,DynamicObj> as dict ->
881
+ let newDict = Dictionary<float,DynamicObj>()
882
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
883
+ newDict |> box
884
+ | :? Dictionary<float32,DynamicObj> as dict ->
885
+ let newDict = Dictionary<float32,DynamicObj>()
886
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
887
+ newDict |> box
888
+ | :? Dictionary<char,DynamicObj> as dict ->
889
+ let newDict = Dictionary<char,DynamicObj>()
890
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
891
+ newDict |> box
892
+ | :? Dictionary<string,DynamicObj> as dict ->
893
+ let newDict = Dictionary<string,DynamicObj>()
894
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
895
+ newDict |> box
896
+ | :? Dictionary<unit,DynamicObj> as dict ->
897
+ let newDict = Dictionary<unit,DynamicObj>()
898
+ for kv in dict do newDict.Add(kv.Key, tryDeepCopyObj kv.Value :?> DynamicObj)
899
+ newDict |> box
900
+
901
+ // And for dictionaries containing DynamicObj as key
902
+ | :? Dictionary<DynamicObj,bool> as dict ->
903
+ let newDict = Dictionary<DynamicObj,bool>()
904
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
905
+ newDict |> box
906
+ | :? Dictionary<DynamicObj,byte> as dict ->
907
+ let newDict = Dictionary<DynamicObj,byte>()
908
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
909
+ newDict |> box
910
+ | :? Dictionary<DynamicObj,sbyte> as dict ->
911
+ let newDict = Dictionary<DynamicObj,sbyte>()
912
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
913
+ newDict |> box
914
+ | :? Dictionary<DynamicObj,int16> as dict ->
915
+ let newDict = Dictionary<DynamicObj,int16>()
916
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
917
+ newDict |> box
918
+ | :? Dictionary<DynamicObj,uint16> as dict ->
919
+ let newDict = Dictionary<DynamicObj,uint16>()
920
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
921
+ newDict |> box
922
+ | :? Dictionary<DynamicObj,int> as dict ->
923
+ let newDict = Dictionary<DynamicObj,int>()
924
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
925
+ newDict |> box
926
+ | :? Dictionary<DynamicObj,uint> as dict ->
927
+ let newDict = Dictionary<DynamicObj,uint>()
928
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
929
+ newDict |> box
930
+ | :? Dictionary<DynamicObj,int64> as dict ->
931
+ let newDict = Dictionary<DynamicObj,int64>()
932
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
933
+ newDict |> box
934
+ | :? Dictionary<DynamicObj,uint64> as dict ->
935
+ let newDict = Dictionary<DynamicObj,uint64>()
936
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
937
+ newDict |> box
938
+ | :? Dictionary<DynamicObj,nativeint> as dict ->
939
+ let newDict = Dictionary<DynamicObj,nativeint>()
940
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
941
+ newDict |> box
942
+ | :? Dictionary<DynamicObj,unativeint> as dict ->
943
+ let newDict = Dictionary<DynamicObj,unativeint>()
944
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
945
+ newDict |> box
946
+ | :? Dictionary<DynamicObj,float> as dict ->
947
+ let newDict = Dictionary<DynamicObj,float>()
948
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
949
+ newDict |> box
950
+ | :? Dictionary<DynamicObj,float32> as dict ->
951
+ let newDict = Dictionary<DynamicObj,float32>()
952
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
953
+ newDict |> box
954
+ | :? Dictionary<DynamicObj,char> as dict ->
955
+ let newDict = Dictionary<DynamicObj,char>()
956
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
957
+ newDict |> box
958
+ | :? Dictionary<DynamicObj,string> as dict ->
959
+ let newDict = Dictionary<DynamicObj,string>()
960
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
961
+ newDict |> box
962
+ | :? Dictionary<DynamicObj,unit> as dict ->
963
+ let newDict = Dictionary<DynamicObj,unit>()
964
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, kv.Value)
965
+ newDict |> box
966
+ | :? Dictionary<DynamicObj,DynamicObj> as dict ->
967
+ let newDict = Dictionary<DynamicObj,DynamicObj>()
968
+ for kv in dict do newDict.Add(tryDeepCopyObj kv.Key :?> DynamicObj, tryDeepCopyObj kv.Value :?> DynamicObj)
969
+ newDict |> box
970
+ #endif
971
+
972
+ // native fallbacks for matching Map/dict, see https://github.com/CSBiology/DynamicObj/issues/47
973
+
974
+ #if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
975
+ | o when FableJS.Dictionaries.isMap o ->
976
+ let o = o |> unbox<Dictionary<obj,obj>>
977
+ let newDict = Dictionary<obj,obj>()
978
+ for kv in o do newDict.Add(tryDeepCopyObj kv.Key, tryDeepCopyObj kv.Value)
979
+ newDict |> box
980
+ | o when FableJS.Dictionaries.isDict o ->
981
+ let o = o |> unbox<Dictionary<obj,obj>>
982
+ let newDict = Dictionary<obj,obj>()
983
+ for kv in o do newDict.Add(tryDeepCopyObj kv.Key, tryDeepCopyObj kv.Value)
984
+ newDict |> box
985
+ #endif
986
+ #if FABLE_COMPILER_PYTHON
987
+ // https://github.com/fable-compiler/Fable/issues/3972
988
+ | o when FablePy.Dictionaries.isDict o ->
989
+ let o = o |> unbox<Dictionary<obj,obj>>
990
+ let newDict = Dictionary<obj,obj>()
991
+ for kv in o do newDict.Add(tryDeepCopyObj kv.Key, tryDeepCopyObj kv.Value)
992
+ newDict |> box
993
+ #endif
994
+
995
+ // These collections of DynamicObj can be cloned recursively
996
+ | :? ResizeArray<DynamicObj> as dyns ->
997
+ box (ResizeArray([for dyn in dyns -> tryDeepCopyObj dyn :?> DynamicObj]))
998
+ #if !FABLE_COMPILER
999
+ // this gets compiled to isArrayLike just the same as ResizeArray, but generates a slightly different result handling, so we only transpile the above.
1000
+ | :? array<DynamicObj> as dyns ->
1001
+ box [|for dyn in dyns -> tryDeepCopyObj dyn :?> DynamicObj|]
1002
+ #endif
1003
+ | :? list<DynamicObj> as dyns ->
1004
+ box [for dyn in dyns -> tryDeepCopyObj dyn :?> DynamicObj]
1005
+
1006
+ // Fable compilable version of typematching against implemented IClonable
1007
+ #if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
1008
+ | o when FableJS.Interfaces.implementsICloneable o -> FableJS.Interfaces.cloneICloneable o
1009
+ #endif
1010
+ #if FABLE_COMPILER_PYTHON
1011
+ // https://github.com/fable-compiler/Fable/issues/3972
1012
+ | o when FablePy.Interfaces.implementsICloneable o -> FablePy.Interfaces.cloneICloneable o
1013
+ #endif
1014
+ #if !FABLE_COMPILER
1015
+ | :? System.ICloneable as clonable -> clonable.Clone()
1016
+ #endif
1017
+
1018
+ | :? DynamicObj as dyn ->
1019
+ let newDyn = DynamicObj()
1020
+ for kv in (dyn.GetProperties(includeInstanceProperties)) do
1021
+ newDyn.SetProperty(kv.Key, tryDeepCopyObj kv.Value)
1022
+ box newDyn
1023
+ | _ -> o
1024
+
1025
+ tryDeepCopyObj o