-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Incorrect culture-specific formatting for Vector64/128/256 types #11604
Comments
I only used
This is mirroring the interfaces we have exposed on |
Ok, I see. That looks broken too.
I think it would be actually fine to hardcode If you hardcode anything and support custom formats at the same time, the combination always leads to odd behaviors. For example: var v = Vector128<double>.Zero;
v = v.WithElement(0, 1000).WithElement(1, 1000);
Console.WriteLine(v.ToString("N0", null)); is going to print
Fixing the
Folks can always do their own formatting when they need to display these. For example, the hardcoded |
So it sounds like the current suggestion is:
Maybe, longer term, we need something which can logically dictate the correct symbols to use when grouping a collection of items and how the elements should be separated? |
@jkotas, seems we have an existing We don't, however, appear to have anything that can be used for the |
That's not that surprising. The programmer specific constructs are generally not localizable, e.g. C# language keywords are not localizable either. (BTW: I believe there was an experiment to localize Excel/VB a long time ago. It looked hilarious - it did not last long.)
I do not think so. For example, the human way to format lists in English is start the first one with upper case letter, separate the items with comma, except the last two that are separated by |
@tannergooding I'm moving to Future as it is not clear this must be fixed for 3.0. If I'm wrong let's move it back and find an owner to fix by July 1st. |
@danmosemsft, the fix here is pretty trivial and just involves using We don't have anything for I'm going to see if someone from the community wants to pick this up; and will put up a PR otherwise. |
Just wanting to ensure I address this as well, since it can't be changed post 3.0... I definitely understand the concern here, but I think that it exists for basically any user-defined struct that represents more than a single value. The best option people have is to either not support globalization at all, which puts a larger burden on the consumer (if, for example, they want to support something like percentages or to display additional digits for debugging purposes), or to say there may be some combinations that render weirdly. I think the latter ends up being more flexible long term and users always have a workaround for cases that do render weirdly (you can use custom numeric format strings to avoid commas, etc). |
I think that's the right option for types that are not meant to be directly displayed in localized UI. Vector64 falls into this category. Another example of type in this category is Tuple/ValueTuple that is hardcoded to format using |
I'm not sure I agree that these types can't or shouldn't be displayable in localized UX. Realistically they are no different from That being said, we can always add The |
Sounds great to me. Should we flip the bug back to 3.0 then? |
Done. I also found someone from the C# Discord community who is going to look at tackling this. I'll make sure it gets in for P7. |
From https://github.com/tannergooding/coreclr/commit/211d963a42c8988770afa4d2edcbe9be0ed0b8a8#r31551940:
@tannergooding I do not think that the use of NumberGroupSeparator is correct. NumberGroupSeparator is the string that is used to separate thousands or similar quantities (like 1,000,000,000 in en-US culture). For example, it is . in number of cultures - that would make the formatting here pretty nonsensical.
I think it is dubious for these vector types to implement IFormattable. I think they should just implement plain vanilla ToString, and do not bother with IFormattable. IFormattable makes sense to types that are meant to be displayed to the user directly. It is not the case here.
The text was updated successfully, but these errors were encountered: