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

Avoid Instance Field Initialization in .NET #39

Open
amanda-mitchell opened this issue Jan 11, 2019 · 2 comments
Open

Avoid Instance Field Initialization in .NET #39

amanda-mitchell opened this issue Jan 11, 2019 · 2 comments
Labels
new analyzer Suggestion for a new analyzer to add

Comments

@amanda-mitchell
Copy link
Contributor

With the same rationale as our internal wiki. Possibly related to #36

@amanda-mitchell amanda-mitchell added the new analyzer Suggestion for a new analyzer to add label Jan 11, 2019
@ddunkin
Copy link
Member

ddunkin commented Feb 22, 2019

From the internal wiki:

In C#, instance fields (i.e. member variables) can be initialized where they are declared. Of course, they are also often set in the constructor. To avoid the necessity to look in both places to determine what the initial value of an instance field is, prefer initialization in constructors rather than where the fields are declared.

@amanda-mitchell
Copy link
Contributor Author

We should consider extending this guidance to initializing auto-implemented properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new analyzer Suggestion for a new analyzer to add
Development

No branches or pull requests

2 participants