Extend and test deepHash through guard handling option values. FSharp did not correctly calculate hash codes for equal option values.
Hotfixed DynamicObj GetHashCode and Equals methods with recursive deephash function.
It was failing for properties containing empty collections (e.g. list<DynamicObj>).
Breaking changes.
Improve DynamicObj GetHashCode and by extension Equals methods with recursive deephash function.
DeepHash covers the following types:
- Primitive types
DynamicObj- IDictionary
- Other IEnumerables (List, Array, Seq, ResizeArray...)
- Option
Breaking changes.
Closed issues:
- Deep copy: add native fallbacks for objects in js/py
- Expand DeepCopy logic to mutable collections that contain primitives
- Add a flag for DeepCopyPropertiesTo that enabled to omit static props
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) -
ResizeArraysandDictionariescontaining any combination of basic F# types -
DictionariescontainingDynamicObjas keys or values in any combination withDynamicObjor 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 implementsICloneable, theClone()method is called on the property. -
DynamicObj(and derived classes): properties that are themselvesDynamicObjinstances 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.
Breaking changes.
- Refactor and improve
Copymethods onDynamicObj:ShallowCopyDynamicProperties: Copies all dynamic properties to a newDynamicObjinstance without trying to prevent reference equality.ShallowCopyDynamicPropertiesTo: Copies all dynamic properties to a targetDynamicObjinstance without trying to prevent reference equality.DeepCopyProperties: Recursively deep copy aDynamicObjinstance (or derived class) with all (static and dynamic) properties. Reinstantiation - and therefore prevention of reference equality - is possible forDynamicObj,array|list|ResizeArray<DynamicObj>, and classes implementingSystem.IcloneableDeepCopyPropertiesTo: Recursively deep copies all (static and dynamic) properties to a targetDynamicObjinstance (or derived class). Reinstantiation - and therefore prevention of reference equality - is possible forDynamicObj,array|list|ResizeArray<DynamicObj>, and classes implementingSystem.Icloneable
Copymethod was therefore removed- Expose
CopyUtilsclass that contains our generic deep copy attempt
- fix GetHashCode member failing for null property values
- Undo
DynObj.combineworking with#DynamicObjas input - this caused issues with ncombining nested DOs of types that inherited from DynamicObj. The type signature has been fixed toDynamicObj(without the flexible#)
- Fix DynObj functions not being inlined (#39)
- Rework API naming
- Many improvements to DynObj API module
- Fix serialization with Newtonsoft.Json
- Add conditional compilation rules to transpilation-specific sections
-
Additions:
-
Bugfixes:
* - Make project fable-compatible
* - Rework project structure by splitting into DynamicObj and DynamicObj.Immutable
* - Add a bunch of tests
* - Backwards incompatible because of renaming and removing some members
* - [Use a strong name for the assembly](https://github.com/CSBiology/DynamicObj/pull/19). This may cause backwards incompatibility on netfx. (thanks [@WhiteBlackGoose](https://github.com/WhiteBlackGoose))
* Fix up some TFM confusions
* - [Rename IDO combine to `combineWith`, which now also preserves the type of the second IDO.](https://github.com/CSBiology/DynamicObj/pull/12/files) (thanks [@WhiteBlackGoose](https://github.com/WhiteBlackGoose))
* - Target .NET 6
* - Add `combine` for IDO
* - [Add `ImmutableDynamicObj`](https://github.com/CSBiology/DynamicObj/pull/4) as the immutable counterpart of `DynamicObj` (thanks [@WhiteBlackGoose](https://github.com/WhiteBlackGoose))
* - Add print formatters for both `DynamicObj` and `ImmutableDynamicObj`
* - [Enable Json serialization for ImmutableDynamicObj](https://github.com/CSBiology/DynamicObj/commit/e7474d2658a234bb94299f12de30625e04f5f407) (thanks [@WhiteBlackGoose](https://github.com/WhiteBlackGoose))
* - target netstandard2.0 and .net5.0
* - add custom Equality and GetHashcode (thanks [@WhiteBlackGoose](https://github.com/WhiteBlackGoose))
* - publish symbols
* - target netstandard2.0
* - Add copy utils
* initial release