-
Notifications
You must be signed in to change notification settings - Fork 965
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
Parse ByteSize
with IFormatProvider
?
#1061
Comments
Can we do it with a new overload? I'm okay with adding overloads; been trying to avoid breaking changes for the most part. |
Yeah, should have clarified I meant an additive public API change. While we're here, there's also a reference to Humanizer/src/Humanizer/Transformer/ToLowerCase.cs Lines 7 to 10 in 12cc400
But not here: Humanizer/src/Humanizer/Transformer/ToUpperCase.cs Lines 5 to 8 in 12cc400
Seems like they should be consistent? Is there any value in allowing a culture-specific transform? |
TBH, it's been so long since I've looked at that code. It does seem odd and I agree that CurrentCulture should be used where appropriate. I'm not sure if having a culture aware one makes a difference, but I'm open to additional overloads that take the culture. |
At minimum we can fix the NullRef here and in
Can't overload the // Better name ideas?
public interface ICulturedStringTransformer : IStringTransformer
{
string Transform(string input, CultureInfo culture);
} With a new overload: public static string Transform(this string input, CultureInfo culture, params ICulturedStringTransformer[] transformers)
{
return transformers.Aggregate(input, (current, stringTransformer) => stringTransformer.Transform(current, culture));
} |
While poking around for #1060 I noticed
CultureInfo.CurrentCulture
inByteSize.TryParse()
:Humanizer/src/Humanizer/Bytes/ByteSize.cs
Line 474 in 1285835
Would you be interested
TryParse
/Parse
overloads that acceptIFormatProvider
? Asking first since it's a public API change.It would check if the
IFormatProvider
is eitherCultureInfo
or aNumberFormatInfo
.The text was updated successfully, but these errors were encountered: