Update AV1523: Favor object and collection initializers over separate statements#362
Open
dennisdoomen wants to merge 1 commit intodevelopfrom
Open
Update AV1523: Favor object and collection initializers over separate statements#362dennisdoomen wants to merge 1 commit intodevelopfrom
dennisdoomen wants to merge 1 commit intodevelopfrom
Conversation
Split from #298. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bkoelman
reviewed
Mar 29, 2026
| }; | ||
|
|
||
| var countries = new List { "Netherlands", "United States" }; | ||
| var countries = new List<string> { "Netherlands", "United States" }; |
Collaborator
There was a problem hiding this comment.
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.
bkoelman
reviewed
Mar 29, 2026
Comment on lines
+25
to
+26
| string[] moreCountries = ["Belgium", "Germany"]; | ||
| string[] allCountries = [..countries, ..moreCountries]; |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates guideline AV1523.
It was split out of #298 so the change can be reviewed independently.
Files:
Part of the replacement for #298.