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

Fluent API with comments breaks code #331

Closed
isaacabraham opened this issue Oct 19, 2018 · 1 comment
Closed

Fluent API with comments breaks code #331

isaacabraham opened this issue Oct 19, 2018 · 1 comment

Comments

@isaacabraham
Copy link

This code (taken from the Program.fs file in the Server project of https://github.com/Zaid-Ajaj/tabula-rasa)

Log.Logger <- 
  LoggerConfiguration() 
    // Suave.SerilogExtensions has native destructuring mechanism
    // this helps Serilog deserialize the fsharp types like unions/records
    .Destructure.FSharpTypes()
    // use package Serilog.Sinks.Console  
    // https://github.com/serilog/serilog-sinks-console
    .WriteTo.Console() 
    // add more sinks etc.
    .CreateLogger()

gets rewritten as:

Log.Logger <- LoggerConfiguration().// Suave.SerilogExtensions has native destructuring mechanism
                                    // this helps Serilog deserialize the fsharp types like unions/records
                                    Destructure.FSharpTypes().// use package Serilog.Sinks.Console  
                                                              // https://github.com/serilog/serilog-sinks-console
                                                              WriteTo.Console().// add more sinks etc.
                                                                                CreateLogger()

which is actually invalid F# and does not build.

Using standard fantomas settings with 120 char line length.

In fact, fluent APIs in general don't get very well formatted e.g.:

Log.Logger <-
    LoggerConfiguration()
        .Destructure.FSharpTypes()
        .WriteTo.Console()
        .CreateLogger()

becomes

Log.Logger <- LoggerConfiguration().Destructure.FSharpTypes().WriteTo.Console().CreateLogger()

Although this is more aesthetic.

@nojaf
Copy link
Contributor

nojaf commented Nov 20, 2018

Fixed in 2.9.1, see online.

@nojaf nojaf closed this as completed Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants