Order of automatically generated field initializations

Hello together,

I hope this is the right place to suggest

suppose I have created the following class stub:

internal class Person {     public string FirstName { get; private set; }     public Person(string firstName)     {         FirstName = firstName;     } }


I now add a LastName property:

internal class Person {     public string FirstName { get; private set; }     public string LastName { get; private set; }     public Person(string firstName)     {         FirstName = firstName;     } }


When I put the caret anywhere within the (highlighted) set accessor and apply the quick fix "Initialize field from constructor(s) parameter", the resulting code then looks like this:

internal class Person {     public string FirstName { get; private set; }     public string LastName { get; private set; }     public Person(string firstName, string lastName)     {         LastName = lastName;         FirstName = firstName;     } }


Note that the order of property assignments neither matches the order of definitions nor the order of constructor parameters. It would be nice if the code looked like this instead:

internal class Person {     public string FirstName { get; private set; }     public string LastName { get; private set; }     public Person(string firstName, string lastName)     {         FirstName = firstName;         LastName = lastName;     } }

Please sign in to leave a comment.