Home
Options

Improved intellisense for object initialization and records?

Having intellisense is great for discoverability but in its current implementation, there's room for improvement. I believe you mentioned that it's using the Roslyn APIs to provide this info so I would have thought this would have been automatic. Perhaps needs some adjustments?

Object initialization:
Intellisense only works for properties if you are adding to the end of the list of members. Anything other than the last stops showing anything at all.

void Main()
{
    var someAccount = new SomeAccount
    {
        // doesn't work
        Email = "john.doe@email.com",
        // works fine
    };
}

public class SomeAccount
{
    public long Id;
    public string Email;
    public string FirstName;
    public string LastName;
}


Records and with expressions:
In a with expression for a record, there is no intellisense support it seems, everything is returned.

void Main()
{
    var someAccount = new SomeAccount(123, "john.doe@email.com", "John", "Doe");
    var newAccount = someAccount with
    {
        // not much help here
    };
}

public record SomeAccount(long Id, string Email, string FirstName, string LastName);

Comments

Sign In or Register to comment.