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

CA2265: Do not compare Span<T> to null or default #123

Open
NightOwl888 opened this issue Nov 20, 2024 · 0 comments · May be fixed by #124
Open

CA2265: Do not compare Span<T> to null or default #123

NightOwl888 opened this issue Nov 20, 2024 · 0 comments · May be fixed by #124
Labels
design is:bug Something isn't working notes:breaking-change Has changes that will break backward compatibility pri:normal
Milestone

Comments

@NightOwl888
Copy link
Owner

This warning started happening when upgrading to the .NET 9 SDK (#122). The decision to use default as equivalent to specifying null in the comparison goes against the grain of Microsoft's design practices. We should instead only consider the null for reference types and consider default(ReadOnlySpan<char>) to be the same as ReadOnlySpan<char>.Empty. See:

https://chatgpt.com/share/673e30d0-6a54-8005-be1f-0f6b207c5e1d

Since this is a breaking change from J2N 2.1, we won't be able to fix this until we have a major version bump.

@NightOwl888 NightOwl888 added is:bug Something isn't working design pri:normal notes:breaking-change Has changes that will break backward compatibility labels Nov 20, 2024
@NightOwl888 NightOwl888 added this to the 3.0 milestone Nov 20, 2024
NightOwl888 added a commit that referenced this issue Nov 20, 2024
…ll. Instead, treat default(ReadOnlySpan<char>) as if it were empty. (fixes #123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design is:bug Something isn't working notes:breaking-change Has changes that will break backward compatibility pri:normal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant