Skip to content

Update AV1523: Favor object and collection initializers over separate statements#362

Open
dennisdoomen wants to merge 1 commit intodevelopfrom
copilot/pr298-update-av1523
Open

Update AV1523: Favor object and collection initializers over separate statements#362
dennisdoomen wants to merge 1 commit intodevelopfrom
copilot/pr298-update-av1523

Conversation

@dennisdoomen
Copy link
Copy Markdown
Owner

This PR updates guideline AV1523.

It was split out of #298 so the change can be reviewed independently.

Files:

  • _rules/1523.md

Part of the replacement for #298.

Split from #298.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
};

var countries = new List { "Netherlands", "United States" };
var countries = new List<string> { "Netherlands", "United States" };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the coding guidelines should dictate the use of one of the following styles, for consistency throughout a codebase:

var countries = new List<string> { "Netherlands", "United States" };

vs:

List<string> countries = new()  { "Netherlands", "United States" };

vs:

List<string> countries = [ "Netherlands", "United States" ];

I'm hesitant because R#/Rider has no support for enforcing it. Either way, the first one is the worst, as it's highlighted as redundant code.

Comment on lines +25 to +26
string[] moreCountries = ["Belgium", "Germany"];
string[] allCountries = [..countries, ..moreCountries];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what the best spacing would be here. I suppose a single space around the brackets? R#/Rider doesn't have a setting for space around .., but there's a (non-configurable) IDE0xxx analyzer that warns about it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants