ionide / FsAutoComplete

F# language server using Language Server Protocol
Other
389 stars 151 forks source link

Improve .NET POCO Initialiser Constructor object documentation, unit -> unit is not useful, we want to see the signature #1224

Open jkone27 opened 5 months ago

jkone27 commented 5 months ago

Details

atm, dotnet reference types constructor just show unit unit if they have an empty constructor, but that is not useful as the developer many time, even for poco objects, wants to see the public properties names, and be suggested with them on how to fill in a common .NET object coming from a nugget library or a C# project.

// empty constructor is currently returned in suggestions from autocomplete for C# Poco classes
() -> ()

is not a useful signature for the developer, because he can also use the object constructor (curly constructor from C#) in F# using parentheses and specifying named arguments

// common C# POCO
public class SomeThing {
   public string PropertyOne { get; set; }
}

// actual "poco" initializer the dev is interested into and to see in docs
new SomeThing(
    PropertyOne="A"
    )

Checklist

baronfel commented 5 months ago

Sounds reasonable! Let me make sure I understand the request:

When triggering completion in a constructor, if at the end of the constructor parameter list, users should see any settable properties (in C# terms this is set or init properties) in the completion list

Is that accurate?

jkone27 commented 5 months ago

Yes indeed, I just find it sometimes painful to work with c# poco objects initialiser from F#, it works but syntax is not clear , not well documented and not suggested by the autocomplete/inline-docs. So I think this can help many beginners , maybe I would also mention that curls in C# are replaced by normal Parents in F#? Or maybe a custom computation expression working only with POCOS like

type MyPoco() =
    member val this.Test = "" with get,set

// only unit -> unit is suggested here, not to fill in with Test property which has a public setter..
let x = new MyPoco()

Would make it even closer to C# for pocos and easier to bridge the gap?