Skip to content

Fix TimeZoneInfo.Equals and TimeZoneInfo.HasSameRules - #88869

Merged
tarekgh merged 7 commits into
dotnet:mainfrom
RenderMichael:main
Jul 16, 2023
Merged

Fix TimeZoneInfo.Equals and TimeZoneInfo.HasSameRules#88869
tarekgh merged 7 commits into
dotnet:mainfrom
RenderMichael:main

Conversation

@RenderMichael

Copy link
Copy Markdown
Contributor

Based on #88641 (comment)

On Linux, different UTC aliases for produce TimeZoneInfos which have all the same rules, but some have _adjustmentRules == null and others _adjustmentRules == []. The corresponding API GetAdjustmentRules() returns an empty array if the underlying value is null:

publicAdjustmentRule[]GetAdjustmentRules()
{
if(_adjustmentRules==null)
{
returnArray.Empty<AdjustmentRule>();
}

publicAdjustmentRule[]GetAdjustmentRules()
{
if(_adjustmentRules==null)
{
returnArray.Empty<AdjustmentRule>();
}

Which implies that these two values are equivalent.

@ghostghost added community-contribution Indicates that the PR has been added by a community member area-System.DateTime labels Jul 13, 2023
@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-datetime
See info in area-owners.md if you want to be subscribed.

Issue Details

Based on #88641 (comment)

On Linux, different UTC aliases for produce TimeZoneInfos which have all the same rules, but some have _adjustmentRules == null and others _adjustmentRules == []. The corresponding API GetAdjustmentRules() returns an empty array if the underlying value is null:

publicAdjustmentRule[]GetAdjustmentRules()
{
if(_adjustmentRules==null)
{
returnArray.Empty<AdjustmentRule>();
}

publicAdjustmentRule[]GetAdjustmentRules()
{
if(_adjustmentRules==null)
{
returnArray.Empty<AdjustmentRule>();
}

Which implies that these two values are equivalent.

Author:RenderMichael
Assignees:-
Labels:

community-contribution, area-System.DateTime

Milestone:-

Comment threadsrc/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs Outdated
Comment threadsrc/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs Outdated
Comment threadsrc/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs Outdated
@RenderMichael

Copy link
Copy Markdown
ContributorAuthor

Build failure is #88868, PTAL @tarekgh

Comment threadsrc/libraries/System.Runtime/tests/System/TimeZoneInfoTests.cs Outdated
@ghostghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jul 16, 2023
@tarekgh

Copy link
Copy Markdown
Member

@RenderMichael all failures are known unrelated issues https://github.com/dotnet/runtime/pull/88869/checks?check_run_id=15059873081. Please try to look at the suggestion #88869 (comment).

@ghostghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Jul 16, 2023
@RenderMichael

Copy link
Copy Markdown
ContributorAuthor

@tarekgh Glad there's a way to express the test's prerequisites in a less ad-hoc way! Ready for review

@tarekgh
tarekgh merged commit 2763624 into dotnet:mainJul 16, 2023
@ghostghost locked as resolved and limited conversation to collaborators Aug 16, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.DateTimecommunity-contributionIndicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@RenderMichael@tarekgh