Skip to content

Releases: d-edge/Diffract

v0.4.0

18 Sep 21:36
Compare
Choose a tag to compare

Improve the handling of null values.

  • For leaf types such as string and System.Uri, if one of the values is null and the other isn't, then the null value is printed as XXX is null, and the non-null value is printed as XXX = <...> 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 case Nullness containing both values.
      • when printed, the null value is printed as XXX is null and the non-null value is printed as XXX is not null.

v0.3.0

08 Feb 14:00
Compare
Choose a tag to compare

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 type T based on a diff function that takes two Ts as argument, and optionally an IDifferFactory that 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 type T by mapping it to a diffable type U.

    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 type T that 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

10 Feb 15:25
Compare
Choose a tag to compare

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.MakeCustom taking a printer function to implement ICustomDiff
  • 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

v0.1.1

02 Dec 14:05
Compare
Choose a tag to compare

NuGet package improvements:

  • Add logo URL #11
  • Add README.md #12

v0.1.0

26 Nov 15:30
Compare
Choose a tag to compare

Initial release.