File tree Expand file tree Collapse file tree 3 files changed +72
-1
lines changed
Fantomas.Core.Tests/Stroustrup Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## 6.3.1 - 2024-03-30
4+
5+ ### Fixed
6+ * HashDirective before closing ` ] ` . [ #3070 ] ( https://github.com/fsprojects/fantomas/issues/3070 )
7+
38## 6.3.0 - 2024-03-15
49
510### Miscellaneous
Original file line number Diff line number Diff line change @@ -95,6 +95,65 @@ let x y = [
9595]
9696"""
9797
98+ [<Test>]
99+ let ``hash directive before closing list bracket , 3070`` () =
100+ formatSourceString
101+ """
102+ let private knownProviders = [
103+ #if !FABLE_COMPILER
104+ (SerilogProvider.isAvailable, SerilogProvider.create)
105+ (MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
106+ #endif
107+ ]
108+ """
109+ config
110+ |> prepend newline
111+ |> should
112+ equal
113+ """
114+ let private knownProviders =
115+ [
116+ #if !FABLE_COMPILER
117+ (SerilogProvider.isAvailable, SerilogProvider.create)
118+ (MicrosoftExtensionsLoggingProvider.isAvailable, MicrosoftExtensionsLoggingProvider.create)
119+ #endif
120+ ]
121+ """
122+
123+ [<Test>]
124+ let ``hash directive before closing list bracket , nested let binding`` () =
125+ formatSourceString
126+ """
127+ let foo bar =
128+ let tfms = [
129+ #if NET6_0_OR_GREATER
130+ "net6.0"
131+ #endif
132+ #if NET7_0_OR_GREATER
133+ "net7.0"
134+ #endif
135+ ]
136+ ()
137+ """
138+ config
139+ |> prepend newline
140+ |> should
141+ equal
142+ """
143+ let foo bar =
144+ let tfms =
145+ [
146+ #if NET6_0_OR_GREATER
147+ "net6.0"
148+ #endif
149+ #if NET7_0_OR_GREATER
150+ "net7.0"
151+ #endif
152+ ]
153+
154+ ()
155+ """
156+
98157[<Test>]
99158let ``synbinding function with array`` () =
100159 formatSourceString
Original file line number Diff line number Diff line change @@ -936,7 +936,14 @@ let addParenIfAutoNln expr f =
936936
937937let indentSepNlnUnindentUnlessStroustrup f ( e : Expr ) ( ctx : Context ) =
938938 let shouldUseStroustrup =
939- isStroustrupStyleExpr ctx.Config e && canSafelyUseStroustrup ( Expr.Node e) ctx
939+ let isArrayOrListWithHashDirectiveBeforeClosingBracket () =
940+ match e with
941+ | Expr.ArrayOrList node -> Seq.isEmpty node.Closing.ContentBefore
942+ | _ -> true
943+
944+ isStroustrupStyleExpr ctx.Config e
945+ && canSafelyUseStroustrup ( Expr.Node e) ctx
946+ && isArrayOrListWithHashDirectiveBeforeClosingBracket ()
940947
941948 if shouldUseStroustrup then
942949 f e ctx
You can’t perform that action at this time.
0 commit comments