Skip to content

Commit

Permalink
Print byref as & in extern function declaration. Fixes #1567. (#1579)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Apr 3, 2021
1 parent f06b359 commit bdabac1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Fantomas.Tests/AttributeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -759,3 +759,24 @@ type internal Handler() =
val mutable mainWindow: Window
end
"""

[<Test>]
let ``& in extern function declaration, 1567`` () =
formatSourceString
false
"""
module Foo =
module Bar =
[<DllImport("Kernel32.dll", SetLastError = true)>]
extern bool GetFileInformationByHandleEx(IntPtr hFile, FILE_INFO_BY_HANDLE_CLASS infoClass, [<Out>] FILE_NAME_INFO& info, uint32 dwBufferSize)
"""
config
|> prepend newline
|> should
equal
"""
module Foo =
module Bar =
[<DllImport("Kernel32.dll", SetLastError = true)>]
extern bool GetFileInformationByHandleEx(IntPtr hFile, FILE_INFO_BY_HANDLE_CLASS infoClass, [<Out>] FILE_NAME_INFO& info, uint32 dwBufferSize)
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4152,6 +4152,7 @@ and genType astContext outerBracket t =
| TFun (t, TTuple ts) -> loop t +> sepArrow +> loopTTupleList ts
| TFuns ts -> col sepArrow ts loop
| TApp (TLongIdent ("nativeptr"), [ t ], true) when (astContext.IsCStylePattern) -> loop t -- "*"
| TApp (TLongIdent ("byref"), [ t ], true) when (astContext.IsCStylePattern) -> loop t -- "&"
| TApp (t, ts, isPostfix) ->
let postForm =
match ts with
Expand Down

0 comments on commit bdabac1

Please sign in to comment.