-
Notifications
You must be signed in to change notification settings - Fork 7
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
Preview version of C# language uses incorrect constructor overloading for arrays #210
Comments
Ohhh that is a very very good point and thanks for the kind words! Thanks for bringing this up @nsentinel
Maybe - it would be a breaking change for sure, so nothing I would consider for |
Thanks for the quick reply, and I'm glad you found my comments interesting and helpful! About removing the overloading from I agree that it is less noticeable, but you can always just call Probably the best option from the current user's point of view would be to really just add the attribute and leave it as is, since this solves the problem for everyone and doesn't break anything. And the nuance of perceiving differences in constructor behavior seems more philosophical to me. |
Indeed - for now that might be the most straightforward solution! I will put this "up for grabs" for folks. |
@nsentinel I "fixed" this on |
Thanks again for bringing this up! |
Thank you for the quick fix, and glad to see that my findings came in handy! |
Thanks for the great library!
First-class Span Types is currently under development. Recent changes, in particular Prefer converting T[] to ReadOnlySpan over Span in overload resolution, also affect the library.
See the following code for an example:
Old behavior vs New behavior
That is, by default, it's now easy to get into an invalid constructor overload when passing a buffer from an array. This is not something that will happen sometime in the future, to get problems you just need to enable the preview version of the language for .NET 9. For example, interesting issues: 1, 2
To resolve this issue, all you need to do now is add the OverloadResolutionPriority attribute
Demo
It might be more correct to remove overloading with
ReadOnlySpan<char>
, for example by adding a static method to create aValueStringBuilder
from a given buffer. For example, .NET without it.The text was updated successfully, but these errors were encountered: