diff --git a/src/Fantomas.Tests/CompilerDirectivesTests.fs b/src/Fantomas.Tests/CompilerDirectivesTests.fs index 9dc31fe41a..1dfd0991e5 100644 --- a/src/Fantomas.Tests/CompilerDirectivesTests.fs +++ b/src/Fantomas.Tests/CompilerDirectivesTests.fs @@ -1006,4 +1006,46 @@ let foo = |> List.rev #endif |> List.sort +""" + +[] +let ``async block inside directive, 576`` () = + formatSourceString false """#if TEST +let f () = + async { + let x = 2 + return x + } +#endif +""" config + |> prepend newline + |> should equal """ +#if TEST +let f() = + async { + let x = 2 + return x + } +#endif +""" + +[] +let ``async block inside directive, TEST`` () = + formatSourceStringWithDefines ["TEST"] """#if TEST +let f () = + async { + let x = 2 + return x + } +#endif +""" config + |> prepend newline + |> should equal """ +#if TEST +let f() = + async { + let x = 2 + return x + } +#endif """ \ No newline at end of file diff --git a/src/Fantomas.Tests/RecordTests.fs b/src/Fantomas.Tests/RecordTests.fs index 686b384e9c..fac78775f4 100644 --- a/src/Fantomas.Tests/RecordTests.fs +++ b/src/Fantomas.Tests/RecordTests.fs @@ -67,7 +67,8 @@ type Element = module RecordSignature /// Represents simple XML elements. type Element = - { /// The attribute collection. + { + /// The attribute collection. Attributes: IDictionary; /// The children collection. diff --git a/src/Fantomas/Context.fs b/src/Fantomas/Context.fs index 5223de2b94..2986c0d9f3 100644 --- a/src/Fantomas/Context.fs +++ b/src/Fantomas/Context.fs @@ -513,7 +513,7 @@ let internal printTriviaContent (c: TriviaContent) (ctx: Context) = // It is hard to always get this right in CodePrinter, so we detect it based on the current code. let addNewline = currentLastLine - |> Option.map(fun line -> line.Trim().Length > 1) + |> Option.map(fun line -> line.Trim().Length > 0) |> Option.defaultValue false let addSpace =