Enable IDE0300/IDE0301/IDE0302 as errors and use collection expressions#119
Merged
jonathanpeppers merged 1 commit intoMay 5, 2026
Merged
Conversation
- Add .editorconfig with IDE0300 (array) and IDE0302 (stackalloc) as errors - Enable EnforceCodeStyleInBuild in Directory.Build.props - Convert all new[] and new T[] initializers to collection expressions - Update README and sample to use collection expression syntax Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR enforces C# collection expression usage across the repo by turning IDE0300/IDE0301/IDE0302 into build errors (via .editorconfig + EnforceCodeStyleInBuild) and updates several code paths and docs to use [...] instead of array initializers.
Changes:
- Add
.editorconfigand enableEnforceCodeStyleInBuildso collection-expression IDE rules are enforced during CI/build. - Update generator output and several code locations to use collection expressions (
[...]) instead ofnew[] { ... }/new int[] { ... }. - Refresh sample and README snippets to match the enforced style.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.editorconfig |
Enables IDE0300/IDE0301/IDE0302 as errors and attempts to analyze generated code. |
Directory.Build.props |
Turns on EnforceCodeStyleInBuild so IDE rules run during dotnet build/CI. |
SortingNetworks.Generators/ScalarEmitter.cs |
Updates generated network array emission to use collection expressions. |
SortingNetworks.Generators/NetworkDatabase.cs |
Converts most stored network/layer arrays to collection expressions. |
SortingNetworks.Tests/SourceGeneratorDriver.cs |
Converts small single-item arrays to collection expressions in test helper code. |
samples/SortingNetworks.Sample/Program.cs |
Updates sample array initialization to collection expression syntax. |
README.md |
Updates usage examples to collection expression syntax. |
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.
Summary
Enforce collection expression usage repo-wide via
.editorconfigandEnforceCodeStyleInBuild.Changes
.editorconfig— New file with IDE0300 (array), IDE0301 (empty), IDE0302 (stackalloc) as errors, plusgenerated_code = analyzedDirectory.Build.props— AddedEnforceCodeStyleInBuildso IDE rules fire duringdotnet build/ CIScalarEmitter.cs— Updated generated code output to emit[...]instead ofnew int[] { ... }NetworkDatabase.cs— Converted allnew[] { ... }→[...]SourceGeneratorDriver.cs— Convertednew[] { ... }→[...]samples/Program.cs— Convertednew int[] { ... }→[...]README.md— Updated examples to use collection expression syntax