Uh oh!
There was an error while loading. Please reload this page.
[libs][Unix] Fix UTC alias lookup - #88641
Conversation
* Fix UTC -> UCT typo * Re-order lookup to match source in the comment linked abovce
ghost
commented
Jul 11, 2023
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.
|
danmoseley
commented
Jul 11, 2023
mdh1418
commented
Jul 11, 2023
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 |
tarekgh
left a comment
There was a problem hiding this comment.
@RenderMichael please add the test and we should be good to go. Thanks!
RenderMichael
commented
Jul 11, 2023
@dotnet-policy-service agree |
The tests are failing with May be you need to change the equality with checking the time zone Id instead. |
RenderMichael
commented
Jul 11, 2023
@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.
Uh oh!
There was an error while loading. Please reload this page.
RenderMichael
commented
Jul 12, 2023
The test failed for some reason. For some reason, the following code is false on Linux but true on Windows: TimeZoneInfoactualUtc=TimeZoneInfo.FindSystemTimeZoneById("UCT");boolresult=TimeZoneInfo.Utc.HasSameRules(actualUtc);Is this an issue or am I missing something? |
On Linux the internal adjustment rules array of |
RenderMichael
commented
Jul 12, 2023
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.
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
@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? |
RenderMichael
commented
Jul 12, 2023
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
mdh1418
commented
Jul 12, 2023
We could, but maybe its unnecessary if all of the UTC aliases TimeZoneInfo objects can be created via |
mdh1418
left a comment
There was a problem hiding this comment.
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 BaseUtcOffsetGetAdjustmentRules()DisplayNameStandardNameDaylightName will be as expected for the Utc aliases!
Thanks for your patience!
RenderMichael
commented
Jul 12, 2023
That's what I tried to do with |
tarekgh
commented
Jul 12, 2023
@mdh1418@RenderMichael if we need to, we can try to fix |
RenderMichael
commented
Jul 13, 2023
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. |
tarekgh
commented
Jul 13, 2023
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. |
tarekgh
left a comment
There was a problem hiding this comment.
Thanks @RenderMichael for your effort getting this done!
RenderMichael
commented
Jul 13, 2023
Always happy to contribute to the software I use every day! |
danmoseley
commented
Jul 13, 2023
@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
akoeplinger
commented
Jul 14, 2023
@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 |
tarekgh
commented
Jul 14, 2023
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.