Skip to content

Commit 64cb126

Browse files
Fantomas format
1 parent 4fd2975 commit 64cb126

File tree

11 files changed

+285
-172
lines changed

11 files changed

+285
-172
lines changed

src/Diffract/DictionaryShape.fs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ open System.Collections.Generic
55
open TypeShape.Core
66

77
type IDictionaryVisitor<'R> =
8-
abstract Visit<'Dict, 'K, 'V when 'K : equality and 'Dict :> IDictionary<'K, 'V>> : unit -> 'R
8+
abstract Visit<'Dict, 'K, 'V when 'K: equality and 'Dict :> IDictionary<'K, 'V>> : unit -> 'R
99

1010
type IShapeDictionary =
11-
abstract Key : TypeShape
12-
abstract Value : TypeShape
13-
abstract Accept : visitor: IDictionaryVisitor<'R> -> 'R
11+
abstract Key: TypeShape
12+
abstract Value: TypeShape
13+
abstract Accept: visitor: IDictionaryVisitor<'R> -> 'R
1414

15-
type private ShapeDictionary<'Dict, 'K, 'V when 'K : equality and 'Dict :> IDictionary<'K, 'V>>() =
15+
type private ShapeDictionary<'Dict, 'K, 'V when 'K: equality and 'Dict :> IDictionary<'K, 'V>>() =
1616
interface IShapeDictionary with
1717
member _.Key = shapeof<'K> :> _
1818
member _.Value = shapeof<'V> :> _
@@ -26,13 +26,11 @@ module Shape =
2626
match s.ShapeInfo with
2727
| Generic (td, ta) when td.FullName = fullName -> Some ta
2828
| _ -> None
29-
| iface ->
30-
Some (iface.GetGenericArguments())
29+
| iface -> Some(iface.GetGenericArguments())
3130

3231
let (|Dictionary|_|) (s: TypeShape) =
3332
match s with
3433
| GenericInterface "System.Collections.Generic.IDictionary`2" ta ->
35-
Activator.CreateInstanceGeneric<ShapeDictionary<_, _, _>>(Array.append [|s.Type|] ta)
36-
:?> IShapeDictionary
34+
Activator.CreateInstanceGeneric<ShapeDictionary<_, _, _>>(Array.append [| s.Type |] ta) :?> IShapeDictionary
3735
|> Some
3836
| _ -> None

src/Diffract/DiffPrinter.fs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,37 @@ open System.IO
44

55
let toStreamImpl (w: TextWriter) param (d: Diff) =
66
let originalParam = param
7-
let param = if originalParam.ensureFirstLineIsAligned then { originalParam with ensureFirstLineIsAligned = false } else originalParam
87

9-
let addPathField path field = if path = "" then field else (path + "." + field)
8+
let param =
9+
if originalParam.ensureFirstLineIsAligned then
10+
{ originalParam with ensureFirstLineIsAligned = false }
11+
else
12+
originalParam
13+
14+
let addPathField path field =
15+
if path = "" then field else (path + "." + field)
16+
1017
let addPathIndex path index = path + "[" + index + "]"
11-
let indentLike str = String.replicate (String.length str) " "
12-
let displayPath path = if path = "" then param.neutralName else path
18+
19+
let indentLike str =
20+
String.replicate (String.length str) " "
21+
22+
let displayPath path =
23+
if path = "" then param.neutralName else path
1324

1425
let printValue indent path x1 x2 =
1526
let dpath = if path = "" then "" else path + " "
1627
w.WriteLine($"%s{indent}%s{dpath}%s{param.x1Name} = %A{x1}")
1728
w.WriteLine($"%s{indent}%s{indentLike dpath}%s{param.x2Name} = %A{x2}")
18-
29+
1930
let rec loop (indent: string) (path: string) (d: Diff) =
2031
match d with
21-
| Diff.Value (x1, x2) ->
22-
printValue indent path x1 x2
23-
| Diff.Record fields when fields.Count = 1 ->
24-
loop indent (addPathField path fields.[0].Name) fields.[0].Diff
32+
| Diff.Value (x1, x2) -> printValue indent path x1 x2
33+
| Diff.Record fields when fields.Count = 1 -> loop indent (addPathField path fields.[0].Name) fields.[0].Diff
2534
| Diff.Record fields ->
2635
w.WriteLine($"%s{indent}%s{displayPath path} differs by %i{fields.Count} fields:")
2736
let indent = indent + param.indent
37+
2838
for field in fields do
2939
loop indent (addPathField path field.Name) field.Diff
3040
| Diff.UnionCase (caseName1, caseName2) ->
@@ -37,35 +47,39 @@ let toStreamImpl (w: TextWriter) param (d: Diff) =
3747
| Diff.UnionField (case, fields) ->
3848
w.WriteLine($"%s{indent}%s{displayPath path} differs by union case %s{case} fields:")
3949
let indent = indent + param.indent
50+
4051
for field in fields do
4152
loop indent (addPathField path field.Name) field.Diff
4253
| Diff.Collection (c1, c2, diffs) ->
4354
w.WriteLine($"%s{indent}%s{displayPath path} collection differs:")
4455
let indent = indent + param.indent
56+
4557
if c1 <> c2 then
4658
let countPath = addPathField path "Count"
4759
w.WriteLine($"%s{indent}%s{countPath} %s{param.x1Name} = %i{c1}")
4860
w.WriteLine($"%s{indent}%s{indentLike countPath} %s{param.x2Name} = %i{c2}")
61+
4962
for item in diffs do
5063
loop indent (addPathIndex path item.Name) item.Diff
51-
| Diff.Custom cd ->
52-
cd.WriteTo(w, param, indent, path, loop)
64+
| Diff.Custom cd -> cd.WriteTo(w, param, indent, path, loop)
5365
| Diff.Dictionary (keysInX1, keysInX2, common) ->
5466
w.WriteLine($"%s{indent}%s{displayPath path} dictionary differs:")
5567
let indent = indent + param.indent
68+
5669
for k in keysInX1 do
5770
w.WriteLine($"%s{indent}%s{param.x2Name}[%s{k}] is missing")
71+
5872
for k in keysInX2 do
5973
w.WriteLine($"%s{indent}%s{param.x1Name}[%s{k}] is missing")
74+
6075
for item in common do
6176
loop indent (addPathIndex path item.Name) item.Diff
6277

6378
match originalParam.ensureFirstLineIsAligned, d with
6479
| true, Diff.Value (x1, x2) ->
6580
w.WriteLine()
6681
printValue "" "" x1 x2
67-
| true, Diff.Custom cd ->
68-
cd.WriteTo(w, originalParam, "", "", loop)
82+
| true, Diff.Custom cd -> cd.WriteTo(w, originalParam, "", "", loop)
6983
| _ -> loop "" "" d
7084

7185
let write (param: PrintParams) (w: TextWriter) (d: Diff option) =

0 commit comments

Comments
 (0)