Skip to content
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

[C# target] Use Collections.EmptyList to prevent zero length allocations #4762

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Corniel
Copy link

@Corniel Corniel commented Jan 24, 2025

I noticed when enabling some static code analysis rules (by setting the property <EnableNETAnalyzers>true</EnableNETAnalyzers> in the csproj file), that CA1825: Avoid zero-length array allocations was raised.

Because the C# solution still targets net4.5 (is that still needed? I would argue that net4.8 or netstandard2.0 should be sufficient, it is 2025 after all) the use of Array.Empty<T> can not be used. However, fortunately, Collections.EmptyList<T> already provided a solution. I just applied them where applicable.

@Corniel Corniel force-pushed the use-collections-empty-list branch from d36f817 to ee12da9 Compare January 24, 2025 09:53
@Corniel Corniel force-pushed the use-collections-empty-list branch from ee12da9 to b5d0bf0 Compare January 24, 2025 09:54
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.

1 participant