Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update style for empty class. #2976

Merged
merged 4 commits into from
Nov 3, 2023
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: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changelog

## Unreleased
## 6.3.0-alpha-001 - 2023-11-03

### Changed
* Remove blank line between type extension. [#2970](https://github.com/fsprojects/fantomas/pull/2970)
* ExperimentalKeepIndentInBranch should fire when first branch was all on one line. [#2973](https://github.com/fsprojects/fantomas/issues/2973)
* Style for empty class. [#2976](https://github.com/fsprojects/fantomas/pull/2976)

## 6.2.3 - 2023-11-2

Expand Down
8 changes: 2 additions & 6 deletions src/Fantomas.Core.Tests/AttributeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,10 @@ type Sample [<ImportingConstructor>] internal () = class end"""
equal
"""
[<Export>]
type Sample [<ImportingConstructor>] (dependency: IDependency) =
class
end
type Sample [<ImportingConstructor>] (dependency: IDependency) = class end

[<Export>]
type Sample [<ImportingConstructor>] internal () =
class
end
type Sample [<ImportingConstructor>] internal () = class end
"""

[<Test>]
Expand Down
16 changes: 4 additions & 12 deletions src/Fantomas.Core.Tests/ClassTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,11 @@ type Class7<'T when 'T : (new : unit -> 'T)>() =
|> should
equal
"""
type Class4<'T when 'T: (static member staticMethod1: unit -> 'T)> =
class
end
type Class4<'T when 'T: (static member staticMethod1: unit -> 'T)> = class end

type Class5<'T when 'T: (member Method1: 'T -> int)> =
class
end
type Class5<'T when 'T: (member Method1: 'T -> int)> = class end

type Class6<'T when 'T: (member Property1: int)> =
class
end
type Class6<'T when 'T: (member Property1: int)> = class end

type Class7<'T when 'T: (new: unit -> 'T)>() =
member val Field = new 'T()
Expand Down Expand Up @@ -854,9 +848,7 @@ type SomeVeryLongTypeNameWithConstructor
aVeryLongType: AVeryLongTypeThatYouNeedToUse,
aSecondVeryLongType: AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType: AVeryLongTypeThatYouNeedToUse
) =
class
end
) = class end
"""

[<Test>]
Expand Down
4 changes: 1 addition & 3 deletions src/Fantomas.Core.Tests/CommentTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1870,9 +1870,7 @@ type MaybeBuilder() = class end
// Maybe computation expression builder, copied from ExtCore library
/// https://github.com/jack-pappas/ExtCore/blob/master/ExtCore/Control.fs
[<Sealed>]
type MaybeBuilder() =
class
end
type MaybeBuilder() = class end
"""

[<Test>]
Expand Down
3 changes: 1 addition & 2 deletions src/Fantomas.Core.Tests/CompilerDirectivesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2988,8 +2988,7 @@ type internal CompilerStateCache(readAllBytes: string -> byte[], projectOptions:
#else
=
#endif
class
end
class end
"""

[<Test>]
Expand Down
4 changes: 1 addition & 3 deletions src/Fantomas.Core.Tests/DallasTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,7 @@ let ``trivia inside implicit constructor`` () =
type MyType
(
(* some comment *)
) =
class
end
) = class end
"""

[<Test>]
Expand Down
4 changes: 1 addition & 3 deletions src/Fantomas.Core.Tests/InterfaceTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,7 @@ type IInterface3 =
|> should
equal
"""
type IInterface =
interface
end
type IInterface = interface end

type IInterface2 =
interface
Expand Down
35 changes: 9 additions & 26 deletions src/Fantomas.Core.Tests/SpaceBeforeClassConstructorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ let ``default config should not add space before unit in uppercase class definit
formatSourceString false "type Person () = class end" config
|> should
equal
"""type Person() =
class
end
"""type Person() = class end
"""

[<Test>]
Expand All @@ -33,9 +31,7 @@ let ``SpaceBeforeUnitParameterInUppercaseClassConstructor should add space after
|> should
equal
"""
type Person () =
class
end
type Person () = class end
"""

// Space before unit in lowercase class definition
Expand All @@ -53,9 +49,7 @@ let ``default config should not add space before unit in lowercase class definit
|> should
equal
"""
type t() =
class
end
type t() = class end
"""

[<Test>]
Expand All @@ -65,17 +59,14 @@ let ``SpaceBeforeUnitParameterInLowercaseClassConstructor should add space befor
formatSourceString
false
"""type t() =
class
end
class end
"""
spaceBeforeConfig
|> prepend newline
|> should
equal
"""
type t () =
class
end
type t () = class end
"""

// Space before parentheses in Uppercase class definition
Expand All @@ -93,9 +84,7 @@ type Animal(length:int) =
|> should
equal
"""
type Animal(length: int) =
class
end
type Animal(length: int) = class end
"""

[<Test>]
Expand All @@ -113,9 +102,7 @@ type Animal(length:int) =
|> should
equal
"""
type Animal (length: int) =
class
end
type Animal (length: int) = class end
"""

// Space before parentheses in lowercase class definition
Expand All @@ -133,9 +120,7 @@ type animal(length:int) =
|> should
equal
"""
type animal(length: int) =
class
end
type animal(length: int) = class end
"""

[<Test>]
Expand All @@ -153,9 +138,7 @@ type animal(length:int) =
|> should
equal
"""
type animal (length: int) =
class
end
type animal (length: int) = class end
"""

// Space before parentheses in secondary class constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,7 @@ type UpdatedName = { PreviousName: string }
|> should
equal
"""
type IEvent =
interface
end
type IEvent = interface end

type SomeEvent = {
Id: string
Expand Down
8 changes: 2 additions & 6 deletions src/Fantomas.Core.Tests/StructTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ type NameStruct = struct end
|> should
equal
"""
type NameStruct =
struct
end
type NameStruct = struct end
"""

[<Test>]
Expand All @@ -160,9 +158,7 @@ type NameStruct() =
|> should
equal
"""
type NameStruct() =
struct
end
type NameStruct() = struct end
"""

[<Test>]
Expand Down
4 changes: 1 addition & 3 deletions src/Fantomas.Core.Tests/SynConstTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ module Runner =
let mPerSecond = 1000<m / second> // foo

[<Measure>]
type ProcessId =
class
end
type ProcessId = class end
"""

[<Test>]
Expand Down
4 changes: 1 addition & 3 deletions src/Fantomas.Core.Tests/TypeAnnotationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ type Meh
LongTupleItemTypeThree *
LongThingFour *
LongThingFiveYow
) =
class
end
) = class end
"""

[<Test>]
Expand Down
68 changes: 17 additions & 51 deletions src/Fantomas.Core.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -609,45 +609,25 @@ type Class14<'T,'U when 'T : equality and 'U : equality> =
|> should
equal
"""
type Class1<'T when 'T :> System.Exception> =
class
end
type Class1<'T when 'T :> System.Exception> = class end

type Class2<'T when 'T :> System.IComparable> =
class
end
type Class2<'T when 'T :> System.IComparable> = class end

type Class3<'T when 'T: null> =
class
end
type Class3<'T when 'T: null> = class end

type Class8<'T when 'T: not struct> =
class
end
type Class8<'T when 'T: not struct> = class end

type Class9<'T when 'T: enum<uint32>> =
class
end
type Class9<'T when 'T: enum<uint32>> = class end

type Class10<'T when 'T: comparison> =
class
end
type Class10<'T when 'T: comparison> = class end

type Class11<'T when 'T: equality> =
class
end
type Class11<'T when 'T: equality> = class end

type Class12<'T when 'T: delegate<obj * System.EventArgs, unit>> =
class
end
type Class12<'T when 'T: delegate<obj * System.EventArgs, unit>> = class end

type Class13<'T when 'T: unmanaged> =
class
end
type Class13<'T when 'T: unmanaged> = class end

type Class14<'T, 'U when 'T: equality and 'U: equality> =
class
end
type Class14<'T, 'U when 'T: equality and 'U: equality> = class end
"""

[<Test>]
Expand Down Expand Up @@ -806,9 +786,7 @@ type t(x : int) =
"""
let f (x : int) = x

type t(x : int) =
class
end
type t(x : int) = class end
"""

[<Test>]
Expand Down Expand Up @@ -1754,9 +1732,7 @@ type DeviceNotificationHandler<'Notification, 'CallbackId, 'RegisterInputData, '
|> should
equal
"""
type INotifications<'a, 'b, 'c, 'd, 'e> =
class
end
type INotifications<'a, 'b, 'c, 'd, 'e> = class end

type DeviceNotificationHandler<'Notification, 'CallbackId, 'RegisterInputData, 'RegisterOutputData, 'UnregisterOutputData>
private
Expand Down Expand Up @@ -2255,9 +2231,7 @@ type C
aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse
)
=
class
end
= class end
"""

[<Test>]
Expand Down Expand Up @@ -2285,9 +2259,7 @@ type C
aSecondVeryLongType : AVeryLongTypeThatYouNeedToUse,
aThirdVeryLongType : AVeryLongTypeThatYouNeedToUse
)
=
class
end
= class end
"""

[<Test>]
Expand Down Expand Up @@ -3188,9 +3160,7 @@ type Event<'Delegate, 'Args when 'Delegate: delegate<'Args, unit> and 'Delegate
equal
"""
type Event<'Delegate, 'Args
when 'Delegate: delegate<'Args, unit> and 'Delegate :> System.Delegate and 'Delegate: not struct>() =
class
end
when 'Delegate: delegate<'Args, unit> and 'Delegate :> System.Delegate and 'Delegate: not struct>() = class end
"""

[<Test>]
Expand All @@ -3209,9 +3179,7 @@ type Event<'Delegate, 'Args when 'Delegate: delegate<'Args, unit> and 'Delegate
type Event<'Delegate, 'Args
when 'Delegate: delegate<'Args, unit>
and 'Delegate :> System.Delegate
and 'Delegate: not struct>() =
class
end
and 'Delegate: not struct>() = class end
"""

[<Test>]
Expand Down Expand Up @@ -3638,9 +3606,7 @@ type Meh
,
c
#endif
) =
class
end
) = class end
"""

[<Test>]
Expand Down
Loading