fsprojects-archive / zzarchive-VisualFSharpPowerTools

[ARCHIVED] Power commands for F# in Visual Studio
http://fsprojects.github.io/VisualFSharpPowerTools/
Apache License 2.0
310 stars 77 forks source link

Formatting removes methods from a struct type #1459

Open nightroman opened 7 years ago

nightroman commented 7 years ago

The original code before formatting (note the position of end, if it is after the methods then methods are not removed on formatting):

    namespace NRText
    open System

    /// Text source record.
    /// Name : Source (file) name.
    /// LineNumber : 1-based line number.
    /// CharNumber : 1-based character number.
    type TextSource =
        struct
            val Name : string
            val LineNumber : int
            val CharNumber : int
            new (name, lineNumber) = { Name = name; LineNumber = lineNumber; CharNumber = 1 }
        end

        member x.TextAsPowerShell() =
            if x.CharNumber = 0 then
                sprintf "At %s:%d" x.Name x.LineNumber
            else
                sprintf "At %s:%d char:%d" x.Name x.LineNumber x.CharNumber

        member x.TextAsVisualStudio() =
            if x.CharNumber = 0 then
                sprintf "%s(%d)" x.Name x.LineNumber
            else
                sprintf "%s(%d,%d)" x.Name x.LineNumber x.CharNumber

        override x.ToString() =
            x.TextAsVisualStudio()

The code after formatting, all methods are gone:

    namespace NRText

    open System

    /// Text source record.
    /// Name : Source (file) name.
    /// LineNumber : 1-based line number.
    /// CharNumber : 1-based character number.
    type TextSource =
        struct
            val Name : string
            val LineNumber : int
            val CharNumber : int
            new(name, lineNumber) =
                { Name = name
                  LineNumber = lineNumber
                  CharNumber = 1 }
        end
cloudRoutine commented 7 years ago

@nightroman formatting errors should be reported at https://github.com/dungpa/fantomas

nightroman commented 7 years ago

Done, https://github.com/dungpa/fantomas/issues/201