-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat: PixelSize TryParse #14979
feat: PixelSize TryParse #14979
Conversation
You can test this PR using the following package version. |
While I have nothing against the API itself, why do we have the ability to provide the separator in In my opinion, I don't think the separator should be able to be specified at all for these methods. We should also think about consistency here. Why don't we have |
Also, shouldn't we rewrite |
My intention is to gradually add the TryParse method to the other types. |
You can test this PR using the following package version. |
I still don't really like the separator being a parameter. As mentioned before, we should only allow the format currently used in XAML. Also, the separator may be ignored since a whitespace will always act as an extra separator in the current For more complex types it may even clash with the decimal separator or other special characters from the format. Since we don't allow the culture to be specified (for good reasons, we're parsing a known format here, not accepting localized user input), the separator shouldn't be either. Pinging @maxkatz6 for a second opinion on this matter. |
You can test this PR using the following package version. |
Maybe you can also provide an overload for |
ReadOnlySpan overload would be nice in general, but we don't have it anywhere else. Could be a candidate for the future PRs.
I would vote to remove separator parameter. As pixel size parsing is always invariant (with '.' decimal point), and ',' as a separator is well common. If it's ever needed, we can add another overload with separator in the future, but not necessary now. |
Also, |
For ReadOnlySpan overloads we'll need to implement some shims for netstandard2.0 that would parse integers/doubles for invariant locale without actually allocating a string. Can probably copy-paste some code from BCL. |
You can test this PR using the following package version. |
@workgroupengineering Can you please remove the separator argument from this PR? |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
Head branch was pushed to by a user without write access
c6d2e1f
to
ab02549
Compare
You can test this PR using the following package version. |
* feat: PixelSize TryParse * test: Add PixelSize Parse and TryParse * fix: Address review * fix: Address Review * fix: Address review
What does the pull request do?
Add TryParse method to PixelSize
What is the current behavior?
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues