diff --git a/src/Fantomas.Tests/ModuleTests.fs b/src/Fantomas.Tests/ModuleTests.fs index c63d5d311d..74260f32d7 100644 --- a/src/Fantomas.Tests/ModuleTests.fs +++ b/src/Fantomas.Tests/ModuleTests.fs @@ -328,4 +328,21 @@ type T() = type T() = interface IDisposable with override x.Dispose() = () +""" + +[] +let ``attribute on module after namespace`` () = + formatSourceString false """namespace SomeNamespace + +[] +module Types = + let a = 5 +""" config + |> prepend newline + |> should equal """ +namespace SomeNamespace + +[] +module Types = + let a = 5 """ \ No newline at end of file diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 2d017d028d..2108662e5a 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -113,7 +113,8 @@ and genModuleOrNamespace astContext (ModuleOrNamespace(ats, px, ao, s, mds, isRe match firstDecl with | None -> rep 2 sepNln | Some mdl -> - sepNlnConsideringTriviaContentBefore mdl.Range +> sepNln + let attrRanges = getRangesFromAttributesFromModuleDeclaration mdl + sepNlnConsideringTriviaContentBeforeWithAttributes mdl.Range attrRanges +> sepNln let genTriviaForLongIdent (f: Context -> Context) = match node with