diff --git a/src/Fantomas.Tests/SignatureTests.fs b/src/Fantomas.Tests/SignatureTests.fs index dd1714697b..22c2d43ea2 100644 --- a/src/Fantomas.Tests/SignatureTests.fs +++ b/src/Fantomas.Tests/SignatureTests.fs @@ -598,4 +598,68 @@ namespace Blah module Foo = val inline sum: ('a -> ^value) -> 'a Foo -> ^value when ^value: (static member (+): ^value * ^value -> ^value) and ^value: (static member Zero: ^value) -""" \ No newline at end of file +""" + +[] +let ``preserve with get property, 945`` () = + formatSourceString true """ +namespace B +type Foo = + | Bar of int + member Item : unit -> int with get +""" { config with SpaceBeforeColon = true } + |> prepend newline + |> should equal """ +namespace B + +type Foo = + | Bar of int + member Item : unit -> int with get +""" + +[] +let ``preserve with set property`` () = + formatSourceString true """ +namespace B +type Foo = + member Item : int -> unit with set +""" { config with SpaceBeforeColon = true } + |> prepend newline + |> should equal """ +namespace B + +type Foo = + member Item : int -> unit with set +""" + +[] +let ``preserve with get,set`` () = + formatSourceString true """ +namespace B + +type Foo = + member Item : int with get, set +""" { config with SpaceBeforeColon = true } + |> prepend newline + |> should equal """ +namespace B + +type Foo = + member Item : int with get, set +""" + +[] +let ``with set after constraint`` () = + formatSourceString true """ +namespace B + +type Foo = + member Item : 't -> unit when 't : comparison with set +""" { config with SpaceBeforeColon = true } + |> prepend newline + |> should equal """ +namespace B + +type Foo = + member Item : 't -> unit when 't : comparison with set +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 0d333ac088..06b138f7fd 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -2405,6 +2405,10 @@ and genMemberSig astContext node = match node with | MSMember(Val(ats, px, ao, s, t, vi, _, ValTyparDecls(tds, _, tcs)), mf) -> let (FunType namedArgs) = (t, vi) + let isFunctionProperty = + match t with + | TFun _ -> true + | _ -> false let sepColonX = match tds with | [] -> sepColon @@ -2417,6 +2421,7 @@ and genMemberSig astContext node = +> sepColonX +> genTypeList astContext namedArgs +> genConstraints astContext t + -- (genPropertyKind (not isFunctionProperty) mf.MemberKind) +> unindent) | MSInterface t -> !- "interface " +> genType astContext false t