Skip to content

Commit

Permalink
genNode for MemberDefn.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Nov 25, 2022
1 parent 38f56ea commit 6c938f2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/Fantomas.Core.Tests/DallasTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1663,3 +1663,28 @@ type internal Set<'T, 'ComparerTag> when 'ComparerTag :> IComparer<'T>(comparer:
static let refresh (s: Set<_, _>) t =
Set<_, _>(comparer = s.Comparer, tree = t)
"""

[<Test>]
let ``comment before inherit member definition`` () =
formatSourceString
false
"""
type ILModuleReader =
abstract ILModuleDef: ILModuleDef
abstract ILAssemblyRefs: ILAssemblyRef list
// ILModuleReader objects only need to be explicitly disposed if memory mapping is used, i.e. reduceMemoryUsage = false
inherit IDisposable
"""
config
|> prepend newline
|> should
equal
"""
type ILModuleReader =
abstract ILModuleDef: ILModuleDef
abstract ILAssemblyRefs: ILAssemblyRef list
// ILModuleReader objects only need to be explicitly disposed if memory mapping is used, i.e. reduceMemoryUsage = false
inherit IDisposable
"""
4 changes: 3 additions & 1 deletion src/Fantomas.Core/CodePrinter2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3516,7 +3516,9 @@ let genMemberDefn (md: MemberDefn) =
genSingleTextNode ic.InheritKeyword
+> sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidth (genInheritConstructor ic)
|> genNode (InheritConstructor.Node ic)
| MemberDefn.Inherit node -> genSingleTextNode node.Inherit +> sepSpace +> genType node.BaseType
| MemberDefn.Inherit node ->
genSingleTextNode node.Inherit +> sepSpace +> genType node.BaseType
|> genNode node
| MemberDefn.ValField node -> genField node
| MemberDefn.Member node -> genBinding node
| MemberDefn.ExternBinding node -> genExternBinding node
Expand Down

0 comments on commit 6c938f2

Please sign in to comment.