-
Notifications
You must be signed in to change notification settings - Fork 293
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
Use Array.Empty<T>() #900
Use Array.Empty<T>() #900
Conversation
Use `Array.Empty<string>()` instead of allocating a new array.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #900 +/- ##
==========================================
- Coverage 68.55% 68.44% -0.12%
==========================================
Files 183 182 -1
Lines 6981 6952 -29
==========================================
- Hits 4786 4758 -28
+ Misses 2195 2194 -1
|
This looks like something that could & should be checked by a linter BTW. Any rules we could enable to catch this automatically? |
There's a built-in rule for this (I forget the number) in fairly recent versions of the .NET SDK (6+ at latest) that should detect such usage if enabled. |
I suppose that it can be detected if you enable The warning: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1825 |
I'd be happy to do a PR to enable that separately - I think otherwise turning it on might find other unrelated diagnostics that need fixing and quickly make the scope of this otherwise small PR spiral. |
Have opened #908 to enable analysers. |
Changes
Use
Array.Empty<string>()
instead of allocating a new array.CHANGELOG.md
updated for non-trivial changes