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

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

Corniel
Copy link
Contributor

@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
@Corniel
Copy link
Contributor Author

Corniel commented Feb 3, 2025

Anyone?

@ericvergnaud
Copy link
Contributor

@parrt blessed

@parrt parrt merged commit d813198 into antlr:dev Feb 5, 2025
28 of 42 checks passed
@Corniel Corniel deleted the use-collections-empty-list branch February 6, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants