Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### 4.0.0-alpha-012 - 06/2020
### 4.0.0-alpha-013 - 07/2020
* WIP for [#705](https://github.com/fsprojects/fantomas/issues/705)
* FCS 36
* FCS 36.0.3
* Replaced json configuration with .editorconfig

### 3.3.0 - 02/2020
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
<Version>4.0.0-alpha-012</Version>
<Version>4.0.0-alpha-013</Version>
<NoWarn>FS0988</NoWarn>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.CoreGlobalTool/Fantomas.CoreGlobalTool.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<ToolCommandName>fantomas</ToolCommandName>
<PackAsTool>True</PackAsTool>
<Version>4.0.0-alpha-012</Version>
<Version>4.0.0-alpha-013</Version>
<AssemblyName>fantomas-tool</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Tests/Fantomas.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\netfx.props" />
<PropertyGroup>
<Version>4.0.0-alpha-012</Version>
<Version>4.0.0-alpha-013</Version>
<NoWarn>FS0988</NoWarn>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
Expand Down
174 changes: 171 additions & 3 deletions src/Fantomas.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,8 @@ let ``member with one long parameter and no return type, 850`` () =
|> prepend newline
|> should equal """
type SomeType =
static member SomeMember loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 =
static member SomeMember loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1
=
printfn "a"
"b"
"""
Expand All @@ -1235,11 +1236,13 @@ let ``multiple members with one long parameter`` () =
|> prepend newline
|> should equal """
type SomeType =
static member SomeMember loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 =
static member SomeMember loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1
=
printfn "a"
"b"

static member Serialize(loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2: SomeType) =
static member Serialize(loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2: SomeType)
=
Encode.string v.Meh

static member Deserialize(loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnngggggggggggJsonVaaaaalueeeeeeeeeeeeeeee)
Expand Down Expand Up @@ -1472,3 +1475,168 @@ type TestType =
// Some more comments
private { Foo: int }
"""

[<Test>]
let ``alternative long member definition`` () =
formatSourceString false """
type C () =
member __.LongMethodWithLotsOfParameters(aVeryLongType : AVeryLongTypeThatYouNeedToUse, aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse) =
someImplementation aVeryLongType aSecondVeryLongType aThirdVeryLongType
""" { config with
SpaceBeforeClassConstructor = true
SpaceBeforeColon = true
AlternativeLongMemberDefinitions = true }
|> prepend newline
|> should equal """
type C () =
member __.LongMethodWithLotsOfParameters
(
aVeryLongType : AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse
)
=
someImplementation aVeryLongType aSecondVeryLongType aThirdVeryLongType
"""

[<Test>]
let ``alternative long member definition with return type`` () =
formatSourceString false """
type C () =
member __.LongMethodWithLotsOfParameters(aVeryLongType : AVeryLongTypeThatYouNeedToUse, aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse) : int =
someImplementation aVeryLongType aSecondVeryLongType aThirdVeryLongType
""" { config with
SpaceBeforeClassConstructor = true
SpaceBeforeColon = true
AlternativeLongMemberDefinitions = true }
|> prepend newline
|> should equal """
type C () =
member __.LongMethodWithLotsOfParameters
(
aVeryLongType : AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse
)
: int
=
someImplementation aVeryLongType aSecondVeryLongType aThirdVeryLongType
"""

// See https://github.com/dotnet/docs/issues/18806#issuecomment-655281219

[<Test>]
let ``member, tuple (non-curried), with return type:`` () =
formatSourceString false """
type MyClass() =
member _.LongMethodWithLotsOfParameters(aVeryLongType: AVeryLongTypeThatYouNeedToUse, aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse, aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse) : AVeryLongReturnType =
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
""" config
|> prepend newline
|> should equal """
type MyClass() =
member _.LongMethodWithLotsOfParameters(aVeryLongType: AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse)
: AVeryLongReturnType =
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
"""

[<Test>]
let ``member, tuple (non-curried), with no return type:`` () =
formatSourceString false """
type MyClass() =
member _.LongMethodWithLotsOfParameters(aVeryLongType: AVeryLongTypeThatYouNeedToUse, aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse, aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse) =
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
""" config
|> prepend newline
|> should equal """
type MyClass() =
member _.LongMethodWithLotsOfParameters(aVeryLongType: AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse) =
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
"""

[<Test>]
let ``member, curried (non-tuple), with return type:`` () =
formatSourceString false """
type MyClass() =
member _.LongMethodWithLotsOfParameters(aVeryLongType: AVeryLongTypeThatYouNeedToUse) (aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse) (aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse) : AVeryLongReturnType =
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
""" config
|> prepend newline
|> should equal """
type MyClass() =
member _.LongMethodWithLotsOfParameters (aVeryLongType: AVeryLongTypeThatYouNeedToUse)
(aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse)
(aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse)
: AVeryLongReturnType =
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
"""

[<Test>]
let ``member, curried (non-tuple), with no return type:`` () =
formatSourceString false """
type MyClass() =
member _.LongMethodWithLotsOfParameters(aVeryLongType: AVeryLongTypeThatYouNeedToUse) (aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse) (aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse) =
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
""" config
|> prepend newline
|> should equal """
type MyClass() =
member _.LongMethodWithLotsOfParameters (aVeryLongType: AVeryLongTypeThatYouNeedToUse)
(aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse)
(aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse)
=
someFunction aVeryLongType aSecondVeryLongType aThirdVeryLongType
"""

[<Test>]
let ``alternative long class constructor`` () =
formatSourceString false """
type C(aVeryLongType: AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse) =
class
end
""" { config with
AlternativeLongMemberDefinitions = true
SpaceBeforeColon = true }
|> prepend newline
|> should equal """
type C
(
aVeryLongType : AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse
)
=
class
end
"""

[<Test>]
let ``alternative long class constructor with access modifier`` () =
formatSourceString false """
type C internal (aVeryLongType: AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse) =
class
end
""" { config with
AlternativeLongMemberDefinitions = true
SpaceBeforeColon = true }
|> prepend newline
|> should equal """
type C
internal
(
aVeryLongType : AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse
)
=
class
end
"""
Loading