Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quick fix to generate a field and initialize from a constructor parameter #15648

Closed
Pilchie opened this issue Dec 2, 2016 · 6 comments
Closed

Comments

@Pilchie
Copy link
Member

Pilchie commented Dec 2, 2016

Generate constructor works the other way, but it would be nice to be able to generate a field and an assignment to it after adding a parameter to a constructor.

class C
{
    public C(string f)
    {
    }
}

With the caret in string f, we should be able to generate a field and initialize it.

@alrz
Copy link
Member

alrz commented Dec 10, 2016

Re "Generate constructor works the other way" I couldn't find it in VS2015U3, how can I use that?

@CyrusNajmabadi
Copy link
Member

Select a bunch of fields/properties. Hit ctrl-<dot>.

@alrz
Copy link
Member

alrz commented Dec 12, 2016

Well that wasn't my first guess, although it makes sense when you know how to do it. Wouldn't it be better to put it on the unassigned field and suggest to initialize (all) fields in the (possibly existing) constructor?

@CyrusNajmabadi
Copy link
Member

There are many different types of interaction models and entry-points that could help improve things here.

From the field. From the constructor. From the parameter. It would be nice to continually improve in this area.

@alrz
Copy link
Member

alrz commented Dec 12, 2016

There are many different types of interaction models and entry-points

@CyrusNajmabadi It seems that currently we don't have any analyzer that works on various entry points? I think these kinds of analyzers belong to a different category, namely "code generation". Perhaps we need a separate menu for all applicable code generation options related to a portion of code e.g. a type.

@Pilchie Pilchie added this to the Unknown milestone Dec 12, 2016
@alrz
Copy link
Member

alrz commented Jan 19, 2017

Probably a duplicate of #8925.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants