fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
772 stars 194 forks source link

Indentation incorrect for code with chained fluent interface method calls #379

Closed bentayloruk closed 5 years ago

bentayloruk commented 5 years ago

Issue created from fantomas-ui

Fantomas has made a mistake with the indenting of method calls in a fluent interface call chains in both blocks of the following code sample.

This automatic issue creation from fantomas-ui is amazing!

Code

let start (args: IArgs) =
    // Serilog configuration
    Log.Logger <-
        LoggerConfiguration()
            .MinimumLevel.Debug()
            .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
            .Enrich.FromLogContext()
            .WriteTo.Console()
            .WriteTo.File(Path.Combine(args.ContentRoot, "temp/log.txt"))
            .CreateLogger()

    try
        try
            let giraffeApp = configureGiraffeApp args
            WebHost.CreateDefaultBuilder()
                .UseWebRoot(args.ClientPath)
                #if DEBUG
                .UseContentRoot(args.ContentRoot)
                .UseUrls(args.Host + ":" + string args.Port)
                #endif
                .UseSerilog()
                .Configure(Action<IApplicationBuilder>(configureApp giraffeApp))
                .ConfigureServices(configureServices args)
                .Build()
                .Run()
            0
        with ex ->
            Log.Fatal(ex, "Host terminated unexpectedly")
            1
    finally
        Log.CloseAndFlush()

Error

let start (args : IArgs) =
    // Serilog configuration
    Log.Logger <-
            LoggerConfiguration()
        .MinimumLevel.Debug()
        .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
        .Enrich.FromLogContext()
        .WriteTo.Console()
        .WriteTo.File(Path.Combine(args.ContentRoot, "temp/log.txt"))
        .CreateLogger()
    try
        try
            let giraffeApp = configureGiraffeApp args
            WebHost.CreateDefaultBuilder().UseWebRoot(args.ClientPath)
#if DEBUG
                   .UseContentRoot(args.ContentRoot)
                   .UseUrls(args.Host + ":" + string args.Port)
#endif

.UseSerilog()
                   .Configure(Action<IApplicationBuilder>
                                  (configureApp giraffeApp))
                   .ConfigureServices(configureServices args).Build().Run()
            0
        with ex ->
            Log.Fatal(ex, "Host terminated unexpectedly")
            1
    finally
        Log.CloseAndFlush()

Options

Fantomas 2.9.1

Name Value
IndentSpaceNum 4
PageWidth 80
PreserveEndOfLine false
SemicolonAtEndOfLine false
SpaceBeforeArgument true
SpaceBeforeColon true
SpaceAfterComma true
SpaceAfterSemicolon true
IndentOnTryWith false
ReorderOpenDeclaration false
SpaceAroundDelimiter true
StrictMode false
jindraivanek commented 5 years ago

Minimalized repro here.