-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Style guide lambda #1858
Style guide lambda #1858
Conversation
f3d21b9
to
c6186e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through the test cases and in almost every case it looks like an improvement to me.
Thanks Don! |
ac0fa7b
to
2160491
Compare
c6186e1
to
e1bb098
Compare
@nojaf Should we merge this? Thanks |
Yes, I've been on holiday for some time so that is the reason why this is has been lingering a bit. One thing that somewhat puzzles me is the disappearance of the FCS 40 prerelease. It is unlisted on NuGet. |
@nojaf Am asking @KevinRansom about the disappearence of the pre-release |
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
Sorry, I unlisted it by mistake, there are some we mean to list, and some we don't mean to list and because it's hard to tell which set something belongs to I unlisted it. However, we have decided to eliminate the need to ship unlisted FSharp.Compiler.Service packages, so from now now on the listing status shouldn't change. Sorry about the inconvenience, and thanks for pointing it out. Kevin |
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
* WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda
* Style guide lambda (fsprojects#1858) * WIP lambda as last argument * Update remaining test according to style proposal. * Add test for multiline non lambda argument. * Print trivia for function keyword from ast range. * multiline non lambda argument, match lambda * WIP Daemon service contract. * Early working daemon prototype. * Take .editorconfig settings into account. * Fix current build. * Add Fantomas locator. * Found globally installed Fantomas version. * Remove unused function. * Add formatSelection. * Refactor FormatDocumentResponse to DU. * Remove unused LspTypes dependency. * Update FCS in Daemon * Refactored public api of FantomasService. * Don't pass full exception in FormatDocumentResponse. * Use separate versioning for Fantomas.Client. * FantomasService manages multiple daemon versions. * Fully implement FantomasService. * Return configuration as json. * Validate if filePath in request is absolute. * Ignore first three 4.6 alphas as compatible tools. * Find ignore file from current file path. * Remove safeFileName from CodeFormatterImpl.fs. Disable daemon tests. * Add daemon unit tests. * Update help text for daemon mode. * Add documentation for Fantomas daemon mode. * Initial attempt at adding source links. * Set DebugType to embedded. * Bump Fantomas.Client to 0.3.0
Hi @dsyme, in order to follow up on dotnet/docs#25207, I've implemented the change in Fantomas to have a better idea of what the impact would be.
I'll explain the high-level gist of the implementation and perhaps you confirm if I understood the guidance correctly.
So, firstly I believe the guidance was focused around function applications where a lambda (be it SynExpr.Lambda or SynExpr.MatchLambda) is the last argument.
I've captured the nested SynExpr.App in an active pattern
(|AppWithLambda|_|)
and applied new logic to that exact shape of SynExpr.First, if the expression is short, we try to put it in one line.
If the
max_line_length
is crossed or the body is multiline, we apply alternative formatting.There, we first check if the function name and arguments until the arrow of the lambda fit on the remainder of the line.
So imagine something like:
If this all still fits on the current line, we write it as such and indent the body one level on the next line.
In case this doesn't fit all argument go on the next line with one level of indent:
This makes a lot of sense to me, especially when
arg1, arg2 or arg3
are multiline themselves.In case the last argument is
SynExpr.MatchLambda
we try the same thing:Or if the max_line_length is crossed:
Notice there is no extra indent on the line after the
function
keyword, the clauses do align with thefunction
keyword.If you look at the implementation, you will see the
MultiLineLambdaClosingNewline
setting.This is to cope with the GR style guide, as they do things differently with lambdas.
So, don't mind that 😊.
Let me know what you think, it would be a great help if you could take a look at the expected results in the unit tests.
Thanks in advance!