-
Notifications
You must be signed in to change notification settings - Fork 641
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
Fix inconsistent number style + replaced clientCulture
with currentCulture (code *was* inconsistent)
#2716
Fix inconsistent number style + replaced clientCulture
with currentCulture (code *was* inconsistent)
#2716
Conversation
Hi @304NotModified, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
@304NotModified, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
Todo
|
I was thinking about this. I think the current solution isn't optimal. I should be: request language => thread culture (UI + normal?) => toString methods with currentCulture. This is more a .Net approach, and also, it fixes the tostrings of datetime etc. This also solves the unit test issue because we can set the current thread culture easily in an unit test. It's a more refactor step than this one. So I fix it now, or in a later PR. What do you think? |
needed for other extensions. Also, in the controller wasn't a nice place for this code.
Analogous name and signature as <see cref="DateTimeExtensions"/>
Except the unit test, this is done. |
Please give me feedback :) besides unit test (where I need feedback for), everything is fixed. |
Note: I have created & tested #2716 (comment) in a separate branch. (not in this PR, yet?) |
Downloads = stats.Downloads.ToString("n0", clientCulture), | ||
UniquePackages = stats.UniquePackages.ToString("n0", clientCulture), | ||
TotalPackages = stats.TotalPackages.ToString("n0", clientCulture), | ||
Downloads = stats.Downloads.ToNuGetNumberString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ToLocalizedNumberString()" sounds more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a minor comment to code (rename method so it's more clear what it does). Regarding the unit test you can:
|
…clientCulture properties/parameters
Thanks for the feedback and review.
Passing the Request wasn't always possible. I could write some more overloads, but everything was getting ugly. I only clean way was to implement my proposal of #2716 (comment) Before executing an action (see I fully removed clientCulture. This is good because:
Status: all done |
clientCulture
clientCulture
clientCulture
with currentCulture (code *was* inconsistent)
Thanks @304NotModified - will give this a thorough look tomorrow but looks sweet so far :) |
OK, I see the unit test still fails at appveyor, but works locally. Have to check that first. I will let you know when it's fixed.
edit: in an unit test "OnActionExecuting" was never called. |
…reIfLanguageHeadersIsPresent
the unit test has been fixed. See build status / succeeding unit tests: https://ci.appveyor.com/project/304NotModified/nugetgallery/build/1.0.20 I needed a trick to execute the "OnActionExecuting" before calling the "action". This is (proper) implemented in the unit test class. |
…Culture (code *was* inconsistent) #2716
Merged into Thanks @304NotModified for your contribution! |
No problem. But I preferred that I had created a new PR to "dev", because now the PR looks un-merged :( |
Ah no worries, that's GitHub I'm afraid. |
fixes #2710
Created C# extensions for:
DetermineClientLocale
=>HttpRequestExtensions
NumberExtensions.ToNuGetNumberString
TODO:
UseClientCultureIfLanguageHeadersIsPresent
fails because I usehttpcontext.current
. Ways to fix this:Request
to the method everywhere instead ofhttpcontext.current
,httpcontext.current
.HttpRequest
inToString
(seeFix inconsistent number style + replaced
clientCulture
with currentCulture (code *was* inconsistent) #2716 (comment)) - I think 1 isn't good, because we're changing code solely for an unit test.