Releases: d-edge/Diffract
v0.5.0
v0.4.0
Improve the handling of null values.
-
For leaf types such as
stringandSystem.Uri, if one of the values is null and the other isn't, then the null value is printed asXXX is null, and the non-null value is printed asXXX = <...>as before. -
For non-leaf types:
- If both values are null, then they're considered equal and do not appear in the diff.
- If one of the values is null, then:
- the
Diff()method returns a new union caseNullnesscontaining both values. - when printed, the null value is printed as
XXX is nulland the non-null value is printed asXXX is not null.
- the
v0.3.0
Add static classes CustomDiffer and CustomDiffer<T> with facilities for creating ICustomDiffers that add support for specific types.
-
CustomDiffer<T>.Build()creates a custom differ for typeTbased on a diff function that takes twoTs as argument, and optionally anIDifferFactorythat can be used to get differs for nested types.type MyRecord = { X: string; Y: string } /// A differ for `MyRecord` that only looks at `X`. let myRecordDiffer = CustomDiffer<MyRecord>.Build(fun differFactory -> let stringDiffer = differFactory.GetDiffer<string>() fun value1 value2 -> stringDiffer.Diff(value1.X, value2.X) )
-
CustomDiffer<T>.Map<U>()creates a custom differ for typeTby mapping it to a diffable typeU.type MyOtherRecord = { X: string; Y: string; Z: string } /// A differ for `MyOtherRecord` that only looks at `X` and `Y`. let myOtherRecordDiffer = CustomDiffer<MyRecord>.Map(fun value -> {| X = value.X; Y = value.Y |})
-
CustomDiffer.Leaf<T>()creates a custom differ for typeTthat treats it as a leaf value using standard equality, customizing the string output.type Username = Username of string /// A differ that treats `Username` as if it was directly an unwrapped string. let usernameDiffer = CustomDiffer.Leaf(fun (Username x) -> x)
-
CustomDiffer.Combine()creates a custom differ for multiple types by combining multiple custom differs.let myDiffer = CustomDiffer.Combine [ myRecordDiffer; myOtherRecordDiffer; usernameDiffer ]
v0.2.0
What's Changed
- Move under DEdge namespace, rename Diffract class to Differ by @Tarmil in #17
- Add PrintParams.ensureFirstLineIsAligned by @Tarmil in #15
- Add
Diff.MakeCustomtaking a printer function to implementICustomDiff - Strip the HTML from README.md before packing by @Tarmil in #13
- docs: add maintainers company by @aloisdg in #18
Full Changelog: v0.1.1...v0.2.0