-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Delegate with many parameters result in a compilation error. #1514
Comments
Hello Michal, thank you for reporting this issue. type SomeWin32Callback =
delegate of
NastyWinApi32Type *
int *
int *
int *
NastyWinApi32Type *
int *
int *
int *
int *
NastyWinApi32Type *
int *
int
-> bool in this case. To solve this, there are two parts. fantomas/src/Fantomas/CodePrinter.fs Lines 3617 to 3622 in a2fd887
Change this to: | ObjectModel (TCDelegate (FunType ts), _, _) ->
let short =
typeName
+> sepEq
+> sepSpace
+> !- "delegate of "
+> genTypeList astContext ts
let long =
typeName
+> sepEq
+> indent
+> sepNln
+> !- "delegate of "
+> genTypeList astContext ts
+> unindent
expressionFitsOnRestOfLine short long The next part is trickier, because of the long tupled definition I would also be splitted on separate lines. fantomas/src/Fantomas/CodePrinter.fs Lines 4246 to 4299 in a2fd887
Add something like: | TParen (TTuple ts'), _ ->
!- "TODO: something clever" Are you interested in submitting a PR? |
@nojaf thanks! I will take a look if I could prepare something : ) |
Thank you, feel free to ask questions you might have along the way. |
Issue created from fantomas-online
Code
Result
Problem description
I want to create a WinApi32 type in my application because this type is a delegate that accepts 8 nasty WinApi32 parameters after Fantomas autosave autoformats generate not compilable code.
I assume that in such a scenario it shouldn't format it at all(?) or use some indentation in new lines.
like:
or
Extra information
If this is indeed an issue I would be glad to help fix it : )
Options
Fantomas version:
4.5.0-alpha-001
Master at 03/08/2021 19:16:36 - a2fd887
Default Fantomas configuration
The text was updated successfully, but these errors were encountered: