From a71e3c375ea1857d87fddd38ebff716b83e28583 Mon Sep 17 00:00:00 2001 From: Josh DeGraw <18509575+josh-degraw@users.noreply.github.com> Date: Wed, 1 Feb 2023 01:27:28 -0700 Subject: [PATCH] Drop `Experimental` prefix from `ExperimentalStroustrup`. (#2755) * Remove experimental prefix from stroustrup bracket style * Update docs * Remove experimental_stroustrup, Configuration.fsx tweaks. --------- Co-authored-by: nojaf --- docs/docs/end-users/Configuration.fsx | 94 ++++++++++--------- fantomas.sln | 1 + .../AlignedMultilineBracketStyleTests.fs | 2 +- src/Fantomas.Core.Tests/DallasTests.fs | 2 +- .../NumberOfItemsListOrArrayTests.fs | 8 +- .../DotIndexedSetExpressionTests.fs | 2 +- .../Stroustrup/DotSetExpressionTests.fs | 2 +- .../Stroustrup/ElmishTests.fs | 2 +- .../FunctionApplicationDualListTests.fs | 2 +- .../FunctionApplicationSingleListTests.fs | 2 +- .../KeepIndentInBranchExpressionTests.fs | 2 +- .../Stroustrup/LambdaExpressionTests.fs | 2 +- .../Stroustrup/LetOrUseBangExpressionTests.fs | 2 +- .../Stroustrup/LongIdentSetExpressionTests.fs | 2 +- ...LineLambdaClosingNewlineExpressionTests.fs | 2 +- .../NamedArgumentExpressionTests.fs | 2 +- .../Stroustrup/SetExpressionTests.fs | 2 +- .../SynBindingFunctionExpressionTests.fs | 2 +- ...ndingFunctionLongPatternExpressionTests.fs | 2 +- ...ngFunctionWithReturnTypeExpressionTests.fs | 2 +- .../SynBindingValueExpressionTests.fs | 2 +- .../SynExprAndBangExpressionTests.fs | 2 +- .../SynMatchClauseExpressionTests.fs | 2 +- .../SynTypeDefnSigReprSimpleTests.fs | 2 +- .../SynTypeDefnSimpleReprRecordTests.fs | 2 +- .../YieldOrReturnBangExpressionTests.fs | 2 +- .../YieldOrReturnExpressionTests.fs | 2 +- src/Fantomas.Core/CodePrinter.fs | 20 ++-- src/Fantomas.Core/Context.fs | 6 +- src/Fantomas.Core/FormatConfig.fs | 12 +-- .../EditorConfigurationTests.fs | 6 +- 31 files changed, 101 insertions(+), 94 deletions(-) diff --git a/docs/docs/end-users/Configuration.fsx b/docs/docs/end-users/Configuration.fsx index b7a2c394a1..72501fc13e 100644 --- a/docs/docs/end-users/Configuration.fsx +++ b/docs/docs/end-users/Configuration.fsx @@ -15,6 +15,12 @@ Your IDE should respect your settings, however the implementation of that is edi UI might be available depending on the IDE. *) +#r "../../../src/Fantomas/bin/Release/net6.0/Fantomas.FCS.dll" +#r "../../../src/Fantomas/bin/Release/net6.0/Fantomas.Core.dll" + +printf $"version: {Fantomas.Core.CodeFormatter.GetVersion()}" +(*** include-output ***) + (** ## Usage Inside .editorconfig you can specify the file extension and code location to be use per config: @@ -28,7 +34,7 @@ fsharp_bar_before_discriminated_union_declaration = true #\ Apply specific settings for a targeted subfolder [src/Elmish/View.fs] -fsharp_multiline_bracket_style = experimental_stroustrup +fsharp_multiline_bracket_style = stroustrup ``` *) @@ -39,13 +45,13 @@ You can quickly try your settings via the *) -#r "nuget: Fantomas.Core, 5.2.0-alpha-012" - -open Fantomas.Core.FormatConfig open Fantomas.Core let formatCode input configIndent = - CodeFormatter.FormatDocumentAsync(false, input, configIndent) + async { + let! result = CodeFormatter.FormatDocumentAsync(false, input, configIndent) + printf $"%s{result.Code}" + } |> Async.RunSynchronously (** @@ -63,7 +69,7 @@ However, there are settings that we do not recommend and generally should not be -` indent_size` has to be between 1 and 10. +`indent_size` has to be between 1 and 10. This preference sets the indentation The common values are 2 and 4. @@ -87,7 +93,7 @@ formatCode """ { FormatConfig.Default with IndentSize = 2 } -(*** include-it ***) +(*** include-output ***) (** @@ -105,7 +111,7 @@ formatCode """ { FormatConfig.Default with MaxLineLength = 60 } -(*** include-it ***) +(*** include-output ***) (** @@ -130,7 +136,7 @@ formatCode """ { FormatConfig.Default with InsertFinalNewline = false } -(*** include-it ***) +(*** include-output ***) (** @@ -148,7 +154,7 @@ formatCode """ { FormatConfig.Default with SpaceBeforeParameter = false } -(*** include-it ***) +(*** include-output ***) (** @@ -169,7 +175,7 @@ match x with """ { FormatConfig.Default with SpaceBeforeLowercaseInvocation = false } -(*** include-it ***) +(*** include-output ***) (** @@ -190,7 +196,7 @@ match x with """ { FormatConfig.Default with SpaceBeforeUppercaseInvocation = true } -(*** include-it ***) +(*** include-output ***) (** @@ -209,7 +215,7 @@ formatCode { FormatConfig.Default with SpaceBeforeClassConstructor = true } -(*** include-it ***) +(*** include-output ***) (** @@ -229,7 +235,7 @@ formatCode """ { FormatConfig.Default with SpaceBeforeMember = true } -(*** include-it ***) +(*** include-output ***) (** @@ -247,7 +253,7 @@ formatCode """ { FormatConfig.Default with SpaceBeforeColon = true } -(*** include-it ***) +(*** include-output ***) (** @@ -264,7 +270,7 @@ formatCode """ { FormatConfig.Default with SpaceAfterComma = false } -(*** include-it ***) +(*** include-output ***) (** @@ -282,7 +288,7 @@ formatCode """ { FormatConfig.Default with SpaceBeforeSemicolon = true } -(*** include-it ***) +(*** include-output ***) (** @@ -300,7 +306,7 @@ formatCode """ { FormatConfig.Default with SpaceAfterSemicolon = false } -(*** include-it ***) +(*** include-output ***) (** @@ -317,7 +323,7 @@ formatCode """ { FormatConfig.Default with SpaceAroundDelimiter = false } -(*** include-it ***) +(*** include-output ***) (** ## Maximum width constraints @@ -341,7 +347,7 @@ formatCode """ { FormatConfig.Default with MaxIfThenShortWidth = 15 } -(*** include-it ***) +(*** include-output ***) (** @@ -358,7 +364,7 @@ formatCode """ { FormatConfig.Default with MaxIfThenElseShortWidth = 10 } -(*** include-it ***) +(*** include-output ***) (** @@ -374,7 +380,7 @@ formatCode """ { FormatConfig.Default with MaxInfixOperatorExpression = 20 } -(*** include-it ***) +(*** include-output ***) (** @@ -393,7 +399,7 @@ formatCode """ { FormatConfig.Default with MaxRecordWidth = 20 } -(*** include-it ***) +(*** include-output ***) (** @@ -425,7 +431,7 @@ formatCode { FormatConfig.Default with MaxRecordNumberOfItems = 2 RecordMultilineFormatter = MultilineFormatterType.NumberOfItems } -(*** include-it ***) +(*** include-output ***) (** @@ -453,7 +459,7 @@ formatCode """ { FormatConfig.Default with RecordMultilineFormatter = MultilineFormatterType.NumberOfItems } -(*** include-it ***) +(*** include-output ***) (** @@ -471,7 +477,7 @@ formatCode """ { FormatConfig.Default with MaxArrayOrListWidth = 20 } -(*** include-it ***) +(*** include-output ***) (** @@ -491,7 +497,7 @@ formatCode { FormatConfig.Default with MaxArrayOrListNumberOfItems = 2 ArrayOrListMultilineFormatter = MultilineFormatterType.NumberOfItems } -(*** include-it ***) +(*** include-output ***) (** @@ -511,7 +517,7 @@ formatCode """ { FormatConfig.Default with ArrayOrListMultilineFormatter = MultilineFormatterType.NumberOfItems } -(*** include-it ***) +(*** include-output ***) (** @@ -530,7 +536,7 @@ formatCode """ { FormatConfig.Default with MaxValueBindingWidth = 10 } -(*** include-it ***) +(*** include-output ***) (** @@ -549,7 +555,7 @@ formatCode """ { FormatConfig.Default with MaxFunctionBindingWidth = 10 } -(*** include-it ***) +(*** include-output ***) (** @@ -569,14 +575,14 @@ formatCode """ { FormatConfig.Default with MaxDotGetExpressionWidth = 100 } -(*** include-it ***) +(*** include-output ***) (** `Cramped` The default way in F# to format brackets. `Aligned` Alternative way of formatting records, arrays and lists. This will align the braces at the same column level. -`ExperimentalStroustrup` Please contribute to [fsprojects/fantomas#1408](https://github.com/fsprojects/fantomas/issues/1408) and engage in [fsharp/fslang-design#706](https://github.com/fsharp/fslang-design/issues/706). +`Stroustrup` Allow for easier reordering of members and keeping the code succinct. Default = Cramped. *) @@ -606,7 +612,7 @@ formatCode """ { FormatConfig.Default with MultilineBracketStyle = Aligned } -(*** include-it ***) +(*** include-output ***) formatCode """ @@ -632,8 +638,8 @@ formatCode (19, 20, 21) |] """ { FormatConfig.Default with - MultilineBracketStyle = ExperimentalStroustrup } -(*** include-it ***) + MultilineBracketStyle = Stroustrup } +(*** include-output ***) (** ## G-Research style @@ -657,7 +663,7 @@ type Range = """ { FormatConfig.Default with NewlineBetweenTypeDefinitionAndMembers = true } -(*** include-it ***) +(*** include-output ***) (** @@ -679,7 +685,7 @@ let run """ { FormatConfig.Default with AlignFunctionSignatureToIndentation = true } -(*** include-it ***) +(*** include-output ***) (** @@ -712,7 +718,7 @@ type D() = """ { FormatConfig.Default with AlternativeLongMemberDefinitions = true } -(*** include-it ***) +(*** include-output ***) (** @@ -740,7 +746,7 @@ let printListWithOffset a list1 = """ { FormatConfig.Default with MultiLineLambdaClosingNewline = true } -(*** include-it ***) +(*** include-output ***) (** @@ -770,7 +776,7 @@ let main argv = """ { FormatConfig.Default with ExperimentalKeepIndentInBranch = true } -(*** include-it ***) +(*** include-output ***) (** @@ -788,7 +794,7 @@ formatCode { FormatConfig.Default with BarBeforeDiscriminatedUnionDeclaration = true } -(*** include-it ***) +(*** include-output ***) (** ## Other @@ -822,7 +828,7 @@ formatCode """ { FormatConfig.Default with BlankLinesAroundNestedMultilineExpressions = false } -(*** include-it ***) +(*** include-output ***) (** @@ -840,7 +846,7 @@ formatCode """ { FormatConfig.Default with KeepMaxNumberOfBlankLines = 1 } -(*** include-it ***) +(*** include-output ***) (** @@ -867,7 +873,7 @@ formatCode """ { FormatConfig.Default with StrictMode = true } -(*** include-it ***) +(*** include-output ***) (** diff --git a/fantomas.sln b/fantomas.sln index ba8edd6db9..f0e27002b7 100644 --- a/fantomas.sln +++ b/fantomas.sln @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{29F22904-C ProjectSection(SolutionItems) = preProject docs\index.html = docs\index.html docs\.README.md = docs\.README.md + docs\docs\end-users\Configuration.fsx = docs\docs\end-users\Configuration.fsx EndProjectSection EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fantomas.Client", "src\Fantomas.Client\Fantomas.Client.fsproj", "{AA895F94-CCF2-4FCF-A9BB-E16987B57535}" diff --git a/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs b/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs index 235ef7f052..9389d84b13 100644 --- a/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs +++ b/src/Fantomas.Core.Tests/AlignedMultilineBracketStyleTests.fs @@ -1526,7 +1526,7 @@ let ``update record in stroustrup style`` () = let v = { rainbow with Boss = "Jeffrey" ; Lackeys = [ "Zippy"; "George"; "Bungle" ] } """ { config with - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } |> prepend newline |> should equal diff --git a/src/Fantomas.Core.Tests/DallasTests.fs b/src/Fantomas.Core.Tests/DallasTests.fs index 039a54707c..2ecbbc8ddd 100644 --- a/src/Fantomas.Core.Tests/DallasTests.fs +++ b/src/Fantomas.Core.Tests/DallasTests.fs @@ -1857,7 +1857,7 @@ let someTest input1 input2 = } """ { config with - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } |> prepend newline |> should equal diff --git a/src/Fantomas.Core.Tests/NumberOfItemsListOrArrayTests.fs b/src/Fantomas.Core.Tests/NumberOfItemsListOrArrayTests.fs index 44a00d904e..6d4caa649a 100644 --- a/src/Fantomas.Core.Tests/NumberOfItemsListOrArrayTests.fs +++ b/src/Fantomas.Core.Tests/NumberOfItemsListOrArrayTests.fs @@ -88,7 +88,7 @@ h [ longValueThatIsALotOfCharactersSoooooLong; longValueThatIsALotOfCharactersSo """ { config with ArrayOrListMultilineFormatter = NumberOfItems - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } |> prepend newline |> should equal @@ -206,7 +206,7 @@ h [ longValueThatIsALotOfCharactersSoooooLong; longValueThatIsALotOfCharactersSo """ { config with ArrayOrListMultilineFormatter = NumberOfItems - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } |> prepend newline |> should equal @@ -240,7 +240,7 @@ h [ longValueThatIsALotOfCharactersSoooooLong; longValueThatIsALotOfCharactersSo """ { config with ArrayOrListMultilineFormatter = NumberOfItems - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } |> prepend newline |> should equal @@ -272,7 +272,7 @@ h [ longValueThatIsALotOfCharactersSoooooLong; longValueThatIsALotOfCharactersSo """ { config with ArrayOrListMultilineFormatter = NumberOfItems - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } |> prepend newline |> should equal diff --git a/src/Fantomas.Core.Tests/Stroustrup/DotIndexedSetExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/DotIndexedSetExpressionTests.fs index f9f69eaf8d..ea829c6124 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/DotIndexedSetExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/DotIndexedSetExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/DotSetExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/DotSetExpressionTests.fs index c9c021c6de..b95a5b7d45 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/DotSetExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/DotSetExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/ElmishTests.fs b/src/Fantomas.Core.Tests/Stroustrup/ElmishTests.fs index 9272a1064e..692a4c36cd 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/ElmishTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/ElmishTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } [] let ``long named arguments should go on newline`` () = diff --git a/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationDualListTests.fs b/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationDualListTests.fs index b2fc44e629..e45b9cd5f7 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationDualListTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationDualListTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } [] let ``two short lists`` () = diff --git a/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationSingleListTests.fs b/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationSingleListTests.fs index 4da71aaef8..5a7d4b6111 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationSingleListTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/FunctionApplicationSingleListTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } [] let ``short function application`` () = diff --git a/src/Fantomas.Core.Tests/Stroustrup/KeepIndentInBranchExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/KeepIndentInBranchExpressionTests.fs index 540cf9a861..55054b5833 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/KeepIndentInBranchExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/KeepIndentInBranchExpressionTests.fs @@ -10,7 +10,7 @@ open Fantomas.Core let config = { config with ExperimentalKeepIndentInBranch = true - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } // There currently is no conflict with this setting, but I'm guessing the case was never brought up. diff --git a/src/Fantomas.Core.Tests/Stroustrup/LambdaExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/LambdaExpressionTests.fs index f42cbad66e..887c056d32 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/LambdaExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/LambdaExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/LetOrUseBangExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/LetOrUseBangExpressionTests.fs index 9bebd3a3cc..9c1376e62d 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/LetOrUseBangExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/LetOrUseBangExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/LongIdentSetExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/LongIdentSetExpressionTests.fs index aa07affc2c..b8f4f287e9 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/LongIdentSetExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/LongIdentSetExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/MultiLineLambdaClosingNewlineExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/MultiLineLambdaClosingNewlineExpressionTests.fs index d94a51d744..26a92441c8 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/MultiLineLambdaClosingNewlineExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/MultiLineLambdaClosingNewlineExpressionTests.fs @@ -8,7 +8,7 @@ open Fantomas.Core let config = { config with MultiLineLambdaClosingNewline = true - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/NamedArgumentExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/NamedArgumentExpressionTests.fs index bd7b190baf..2e6a07ead7 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/NamedArgumentExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/NamedArgumentExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/SetExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SetExpressionTests.fs index 5019f4c81c..d175588d89 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SetExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SetExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionExpressionTests.fs index 5d4a2d4b46..4bef1fbbe4 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionLongPatternExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionLongPatternExpressionTests.fs index 1db23e704e..3c990d3c51 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionLongPatternExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionLongPatternExpressionTests.fs @@ -8,7 +8,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with MaxLineLength = 80 - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } // TODO: conclude on what should happen here diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionWithReturnTypeExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionWithReturnTypeExpressionTests.fs index 46fe7938ca..721d834f4c 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionWithReturnTypeExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynBindingFunctionWithReturnTypeExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynBindingValueExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynBindingValueExpressionTests.fs index d0c0e4c638..0f6eef956c 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynBindingValueExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynBindingValueExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynExprAndBangExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynExprAndBangExpressionTests.fs index 19f80e7752..d74b31ded0 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynExprAndBangExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynExprAndBangExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynMatchClauseExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynMatchClauseExpressionTests.fs index f16e94a968..aa8b9ca295 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynMatchClauseExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynMatchClauseExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSigReprSimpleTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSigReprSimpleTests.fs index 2f4698f006..3fdb9c16eb 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSigReprSimpleTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSigReprSimpleTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } [] let ``record type definition`` () = diff --git a/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSimpleReprRecordTests.fs b/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSimpleReprRecordTests.fs index 8c86841863..fa6cbce5aa 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSimpleReprRecordTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSimpleReprRecordTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core let config = { config with - MultilineBracketStyle = ExperimentalStroustrup } + MultilineBracketStyle = Stroustrup } [] let ``record type definition`` () = diff --git a/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnBangExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnBangExpressionTests.fs index 3d61264029..80e58f97fc 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnBangExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnBangExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnExpressionTests.fs b/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnExpressionTests.fs index 1d7841e7cb..7a859b8610 100644 --- a/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnExpressionTests.fs +++ b/src/Fantomas.Core.Tests/Stroustrup/YieldOrReturnExpressionTests.fs @@ -7,7 +7,7 @@ open Fantomas.Core.Tests.TestHelper let config = { config with - MultilineBracketStyle = ExperimentalStroustrup + MultilineBracketStyle = Stroustrup MaxArrayOrListWidth = 40 } [] diff --git a/src/Fantomas.Core/CodePrinter.fs b/src/Fantomas.Core/CodePrinter.fs index d130754c97..2e9c7b9163 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -502,11 +502,11 @@ let genExpr (e: Expr) = | RecordNodeExtra.With we -> genSingleTextNode node.OpeningBrace +> ifElseCtx - (fun ctx -> ctx.Config.ExperimentalStroustrupStyle) + (fun ctx -> ctx.Config.IsStroustrupStyle) (indent +> sepNln) addSpaceIfSpaceAroundDelimiter +> genCopyExpr fieldsExpr we - +> onlyIfCtx (fun ctx -> ctx.Config.ExperimentalStroustrupStyle) unindent + +> onlyIfCtx (fun ctx -> ctx.Config.IsStroustrupStyle) unindent +> sepNln +> genSingleTextNode node.ClosingBrace | RecordNodeExtra.None -> @@ -633,11 +633,11 @@ let genExpr (e: Expr) = | Some ci -> genSingleTextNodeSuffixDelimiter node.OpeningBrace +> ifElseCtx - (fun ctx -> ctx.Config.ExperimentalStroustrupStyle) + (fun ctx -> ctx.Config.IsStroustrupStyle) (indent +> sepNln) sepNlnWhenWriteBeforeNewlineNotEmpty // comment after curly brace +> genCopyExpr fieldsExpr ci - +> onlyIfCtx (fun ctx -> ctx.Config.ExperimentalStroustrupStyle) unindent + +> onlyIfCtx (fun ctx -> ctx.Config.IsStroustrupStyle) unindent +> sepNln +> genSingleTextNode node.ClosingBrace | None -> @@ -2116,7 +2116,7 @@ let genFunctionNameWithMultilineLids (trailing: Context -> Context) (longIdent: |> genNode parentNode let (|EndsWithDualListApp|_|) (config: FormatConfig) (appNode: ExprAppNode) = - if not config.ExperimentalStroustrupStyle then + if not config.IsStroustrupStyle then None else let mutable otherArgs = ListCollector() @@ -2133,7 +2133,7 @@ let (|EndsWithDualListApp|_|) (config: FormatConfig) (appNode: ExprAppNode) = visit appNode.Arguments let (|EndsWithSingleListApp|_|) (config: FormatConfig) (appNode: ExprAppNode) = - if not config.ExperimentalStroustrupStyle then + if not config.IsStroustrupStyle then None else let mutable otherArgs = ListCollector() @@ -3220,9 +3220,9 @@ let genTypeDefn (td: TypeDefn) = +> genMemberDefnList members match ctx.Config.MultilineBracketStyle with - | ExperimentalStroustrup when hasNoMembers -> stroustrupWithoutMembers ctx + | Stroustrup when hasNoMembers -> stroustrupWithoutMembers ctx | Aligned - | ExperimentalStroustrup -> aligned ctx + | Stroustrup -> aligned ctx | Cramped when anyFieldHasXmlDoc -> aligned ctx | Cramped -> cramped ctx @@ -3246,7 +3246,7 @@ let genTypeDefn (td: TypeDefn) = let size = getRecordSize ctx node.Fields let short = bodyExpr size - if ctx.Config.ExperimentalStroustrupStyle && hasNoMembers then + if ctx.Config.IsStroustrupStyle && hasNoMembers then (sepSpace +> short) ctx else isSmallExpression size short (indentSepNlnUnindent short) ctx @@ -3258,7 +3258,7 @@ let genTypeDefn (td: TypeDefn) = fun (ctx: Context) -> (match node.Type with - | Type.AnonRecord _ when not hasMembers && ctx.Config.ExperimentalStroustrupStyle -> + | Type.AnonRecord _ when not hasMembers && ctx.Config.IsStroustrupStyle -> header +> sepSpaceOrIndentAndNlnIfTypeExceedsPageWidthUnlessStroustrup genType node.Type |> genNode node diff --git a/src/Fantomas.Core/Context.fs b/src/Fantomas.Core/Context.fs index 4886ef6694..dd65d6dca3 100644 --- a/src/Fantomas.Core/Context.fs +++ b/src/Fantomas.Core/Context.fs @@ -753,7 +753,7 @@ let sepSpaceOrDoubleIndentAndNlnIfExpressionExceedsPageWidth expr (ctx: Context) ctx let isStroustrupStyleExpr (config: FormatConfig) (e: Expr) = - let isStroustrupEnabled = config.MultilineBracketStyle = ExperimentalStroustrup + let isStroustrupEnabled = config.MultilineBracketStyle = Stroustrup match e with | Expr.Record node when isStroustrupEnabled -> @@ -770,7 +770,7 @@ let isStroustrupStyleExpr (config: FormatConfig) (e: Expr) = | _ -> false let isStroustrupStyleType (config: FormatConfig) (t: Type) = - let isStroustrupEnabled = config.MultilineBracketStyle = ExperimentalStroustrup + let isStroustrupEnabled = config.MultilineBracketStyle = Stroustrup match t with | Type.AnonRecord _ when isStroustrupEnabled -> true @@ -896,7 +896,7 @@ let ifAlignOrStroustrupBrackets f g = (fun ctx -> match ctx.Config.MultilineBracketStyle with | Aligned - | ExperimentalStroustrup -> true + | Stroustrup -> true | Cramped -> false) f g diff --git a/src/Fantomas.Core/FormatConfig.fs b/src/Fantomas.Core/FormatConfig.fs index 115e0b4dea..b62da15643 100644 --- a/src/Fantomas.Core/FormatConfig.fs +++ b/src/Fantomas.Core/FormatConfig.fs @@ -26,19 +26,19 @@ type MultilineFormatterType = type MultilineBracketStyle = | Cramped | Aligned - | ExperimentalStroustrup + | Stroustrup static member ToConfigString(cfg: MultilineBracketStyle) = match cfg with | Cramped -> "cramped" | Aligned -> "aligned" - | ExperimentalStroustrup -> "experimental_stroustrup" + | Stroustrup -> "stroustrup" static member OfConfigString(cfgString: string) = match cfgString with | "cramped" -> Some Cramped | "aligned" -> Some Aligned - | "experimental_stroustrup" -> Some ExperimentalStroustrup + | "stroustrup" -> Some Stroustrup | _ -> None [] @@ -210,8 +210,8 @@ type FormatConfig = BarBeforeDiscriminatedUnionDeclaration: bool [] - [] - [] + [] + [] MultilineBracketStyle: MultilineBracketStyle [] @@ -223,7 +223,7 @@ type FormatConfig = [] StrictMode: bool } - member x.ExperimentalStroustrupStyle = x.MultilineBracketStyle = ExperimentalStroustrup + member x.IsStroustrupStyle = x.MultilineBracketStyle = Stroustrup static member Default = { IndentSize = 4 diff --git a/src/Fantomas.Tests/EditorConfigurationTests.fs b/src/Fantomas.Tests/EditorConfigurationTests.fs index 45158793b0..7eadffe4cb 100644 --- a/src/Fantomas.Tests/EditorConfigurationTests.fs +++ b/src/Fantomas.Tests/EditorConfigurationTests.fs @@ -448,13 +448,13 @@ insert_final_newline = false Assert.IsFalse config.InsertFinalNewline [] -let ``fsharp_multiline_bracket_style = experimental_stroustrup`` () = +let ``fsharp_multiline_bracket_style = stroustrup`` () = let rootDir = tempName () let editorConfig = """ [*.fs] -fsharp_multiline_bracket_style = experimental_stroustrup +fsharp_multiline_bracket_style = stroustrup """ use configFixture = @@ -464,7 +464,7 @@ fsharp_multiline_bracket_style = experimental_stroustrup let config = EditorConfig.readConfiguration fsharpFile.FSharpFile - Assert.AreEqual(ExperimentalStroustrup, config.MultilineBracketStyle) + Assert.AreEqual(Stroustrup, config.MultilineBracketStyle) [] let ``fsharp_multiline_bracket_style = aligned`` () =