dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.89k stars 783 forks source link

Suggestion: Auto-generate record fields when creating a record value #3748

Open cmeeren opened 7 years ago

cmeeren commented 7 years ago

It would be great if the IDE could generate record field labels when you create a record value.

Given this type:

type MyType =
  {Field1: string
   Field2: int
   Field3: bool}

When I write:

let value = 
  {Field1 =<caret here>

I want to be able to execute a quick action or similar so that I end up with the following:

let value = 
  {Field1 =<caret here>
   Field2 = 
   Field3 = }

I realize of course that this might assume one particular style of writing structs, which complicates this a bit.

On the topmost level, what I want is to not have to remember (or look up the definition) and manually type all field names all the time (nor do I want to type those I remember and wait for the IDE to tell me the rest when static analysis fails).

isaacabraham commented 7 years ago

In terms of UI experience, this is something offered in both VFPT and in Ionide so we could use them both as a starting point. VFPT offers some configuration options for what to put on the RHS.

realvictorprm commented 7 years ago

I thought about implementing this because I noticed it was in the VFPT's. Any more requests?

Am 13.10.2017 8:13 nachm. schrieb "Isaac Abraham" <notifications@github.com

:

In terms of UI experience, this is something offered in both VFPT and in Ionide so we could use them both as a starting point. VFPT offers some configuration options for what to put on the RHS.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/visualfsharp/issues/3748#issuecomment-336528541, or mute the thread https://github.com/notifications/unsubscribe-auth/AYPM8LKkjUuxHXHD1-xw6bFsKAB3Ev-iks5sr6hRgaJpZM4P4zLB .

cmeeren commented 7 years ago

Three of my colleagues would also certainly love this.

realvictorprm commented 7 years ago

Sounds good, OK let me see :)

Am 13.10.2017 20:52 schrieb "Christer van der Meeren" < notifications@github.com>:

Three of my colleagues would also certainly love this.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/visualfsharp/issues/3748#issuecomment-336537852, or mute the thread https://github.com/notifications/unsubscribe-auth/AYPM8IGHVYiq4vNZEPCZudwlWE3BCZJMks5sr7FagaJpZM4P4zLB .

kerams commented 2 years ago

What about ambiguities caused by records with common field names? Can quick action/code fix menus have multiple levels, allowing you to choose the right type? I think I've seen that kind of thing in C#.