Skip to content

Enable IDE0300/IDE0301/IDE0302 as errors and use collection expressions#119

Merged
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers/fix-ide0302-collection-expressions
May 5, 2026
Merged

Enable IDE0300/IDE0301/IDE0302 as errors and use collection expressions#119
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers/fix-ide0302-collection-expressions

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Owner

Summary

Enforce collection expression usage repo-wide via .editorconfig and EnforceCodeStyleInBuild.

Changes

  • .editorconfig — New file with IDE0300 (array), IDE0301 (empty), IDE0302 (stackalloc) as errors, plus generated_code = analyzed
  • Directory.Build.props — Added EnforceCodeStyleInBuild so IDE rules fire during dotnet build / CI
  • ScalarEmitter.cs — Updated generated code output to emit [...] instead of new int[] { ... }
  • NetworkDatabase.cs — Converted all new[] { ... }[...]
  • SourceGeneratorDriver.cs — Converted new[] { ... }[...]
  • samples/Program.cs — Converted new int[] { ... }[...]
  • README.md — Updated examples to use collection expression syntax

- 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>
Copilot AI review requested due to automatic review settings May 5, 2026 02:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 .editorconfig and enable EnforceCodeStyleInBuild so collection-expression IDE rules are enforced during CI/build.
  • Update generator output and several code locations to use collection expressions ([...]) instead of new[] { ... } / 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.

Comment thread .editorconfig
Comment thread .editorconfig
@jonathanpeppers jonathanpeppers merged commit 4ec820d into main May 5, 2026
10 checks passed
@jonathanpeppers jonathanpeppers deleted the jonathanpeppers/fix-ide0302-collection-expressions branch May 5, 2026 19:41
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