-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[libs][Unix] Fix UTC alias lookup #88641
Conversation
* Fix UTC -> UCT typo * Re-order lookup to match source in the comment linked abovce
Tagging subscribers to this area: @dotnet/area-system-datetime Issue Details
I noticed #88368 introduced this bug. Not sure if this should have a regression test, or where such a test would go.
|
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.
Etc/UCT is clearly a valid alias @mdh1418 can you point to the right place for a test?
Thanks for the catch @RenderMichael! I believe TimeZoneInfoTests would be a good place for a test. Perhaps we can all of the aliases to the test data (sans UTC which should be in runtime/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs Lines 2309 to 2338 in 4e48d2d
TimeZoneDisplayNames_Unix can catch if they will have the correct DisplayName, StandardName, and DaylightName.
|
Hardcoding all UTC aliases in the test that @mdh1418 is a good idea. Just ensure adding them under the |
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.
@RenderMichael please add the test and we should be good to go. Thanks!
@dotnet-policy-service agree |
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.
Thanks @RenderMichael
The tests are failing with
May be you need to change the equality with checking the time zone Id instead. |
@tarekgh Sorry I wasn't on my Linux box at the time and use GitHub's text editor. Looks like two However, their |
Maybe it is better to check the |
Compare everything except tests.
The test failed for some reason. For some reason, the following code is false on Linux but true on Windows: TimeZoneInfo actualUtc = TimeZoneInfo.FindSystemTimeZoneById("UCT");
bool result = TimeZoneInfo.Utc.HasSameRules(actualUtc); Is this an issue or am I missing something? |
On Linux the internal adjustment rules array of |
Seems like a pit of failure to me, a pit I tripped into writing this PR. Either way, the feedback has been addressed, PTAL |
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.
Can we also have the other Utc Aliases added to the test data SystemTimeZonesTestData
?
I believe that the BaseUtcOffset and AdjustmentRules were still correct before the typo was fixed (atleast on Android), the thing that slipped through were the DisplayName, StandardName, and DaylightName, and TimeZoneDisplayNames_Unix
would check the values of those three
I believe the public getter GetAdjustmentRules()
for the internal field _adjustmentRules
would still return the Array.Empty<AdjustmentRule>()
even if the value is null
.
runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs
Lines 142 to 145 in a3c21b9
if (_adjustmentRules == null) | |
{ | |
return Array.Empty<AdjustmentRule>(); | |
} |
@mdh1418 before this change, could you create the time zone in the first place? or we get some failure? Did you try it?
Yes, what is the point here? |
runtime/src/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs Lines 2323 to 2330 in 4e48d2d
I see the missing values in this loop are ignored, should we do the same for the UTC aliases @mdh1418 ? |
Yes, I ran a test like
and it gave something like
So the TimeZoneInfo was created for
Just pointing out that If one were to typo in the future, the test would pass (because we are checking for |
Remove previous test which doesn't hit relevant functinality
We could, but maybe its unnecessary if all of the UTC aliases TimeZoneInfo objects can be created via |
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.
I think the other test you proposed was still a good idea cause there doesn't seem to be any other tests checking for the BaseUtcOffset
and GetAdjustmentRules()
for UTC and its aliases. So together all 5 fields BaseUtcOffset
GetAdjustmentRules()
DisplayName
StandardName
DaylightName
will be as expected for the Utc aliases!
Thanks for your patience!
That's what I tried to do with |
@mdh1418 @RenderMichael if we need to, we can try to fix |
Failures are related (some of them)
An issue like this happens for browser but I found that locally and disabled the aliases from @tarekgh @mdh1418 Assuming this isn't a real issue, should we really just gate the alises behind "if not Browser and not tvOS and not iOS"? I'm not familiar with how .NET works on platforms besides Windows and Linux. |
Consistency is good here if we can return the same data in other OSs. But we have differences anyway on such OSs because they carry different sets of data. So, I am not super worried about this specific case. |
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.
Thanks @RenderMichael for your effort getting this done!
Always happy to contribute to the software I use every day! |
@RenderMichael if you're interested in another contribution, we'd welcome it. There's some approved API's that just need implementation, eg. |
The UTC alias test cases failed there after #88641
@tarekgh the tests mentioned in #88641 (comment) are failing in main now. I assume this affects all platforms where we use our own ICU (currently Browser, iOS, tvOS, MacCatalyst) so we should disable the tests there as well, I opened #88909 |
Thanks @akoeplinger for the quick fix. |
I noticed #88368 introduced this bug.
Not sure if this should have a regression test, or where such a test would go.