fsprojects / fantomas

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

Fantomas 2.9.1 formats F# Asp.net Core template into code with compiler errors #403

Closed DavidKarlas closed 5 years ago

DavidKarlas commented 5 years ago

Issue created from fantomas-ui

Compiler errors: Program.fs(13,13): Error FS0010: Unexpected symbol '.' in binding. Expected incomplete structured construct at or before this point or other token. (FS0010) (fsharp1322) Program.fs(5,5): Error FS3118: Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword. (FS3118) (fsharp1322) Program.fs(1,1): Error FS0010: Incomplete structured construct at or before this point in implementation file. Expected incomplete structured construct at or before this point or other token. (FS0010) (fsharp1322)

Code

namespace Company.WebApplication1

open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.Logging

module Program =
    let exitCode = 0

    let BuildWebHost args =
        WebHost
            .CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build()

    [<EntryPoint>]
    let main args =
        BuildWebHost(args).Run()

        exitCode

Error

namespace Company.WebApplication1

open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.Logging

module Program =
    let exitCode = 0
    let BuildWebHost args = WebHost.CreateDefaultBuilder(args).UseStartup<Startup>()
            .Build()

    [<EntryPoint>]
    let main args =
        BuildWebHost(args).Run()
        exitCode

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
nojaf commented 5 years ago

Latest code from master formats as followed:

    let BuildWebHost args =
        WebHost.CreateDefaultBuilder(args).UseStartup<Startup>()
            .Build()

Could you try the nightly version and verify it is still an issue?

DavidKarlas commented 5 years ago

I tried to add 2.9.1-latest but I'm too much of noob with paket to convice it to pull from myget, can someone else try?

jindraivanek commented 5 years ago

@DavidKarlas You can try it as dotnet tool:

dotnet tool install fantomas-tool -g --add-source https://myget.org/F/fantomas/api/v3/index.json --framework netcoreapp2.1 --version 2.9.1-latest

then you should be able to run fantomas source-file.fs


It looks like that we have bad formatted dotnet tool install command in README, if I copy-paste it don't have https:// before myget.org and it fails.

jindraivanek commented 5 years ago

And I can confirm it works correctly on my machine.

DavidKarlas commented 5 years ago

I guess we can close this, when is 2.9.2 planned?

nojaf commented 5 years ago

We have somewhere begin February in mind.