Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

TimeZoneInfoTests.TestGetSystemTimeZones fails on Android because GetSystemTimeZones() returns UTC aliases (UCT, Etc/UTC, Zulu, etc.) alongside UTC, all sharing the same display name "(UTC) Coordinated Universal Time".

Changes

  • Skip UTC aliases in PopulateAllSystemTimeZones using existing IsUtcAlias() check
  • UTC itself is explicitly added to the dictionary before the loop, so it remains in the list
foreach (string timeZoneId in GetTimeZoneIds())
{
    // Skip UTC aliases to avoid duplicate display names in the list.
    // UTC is already added to the dictionary at the start.
    if (IsUtcAlias(timeZoneId))
    {
        continue;
    }
    // ... rest of population logic
}

Fixes #121963

Original prompt

This section details on the original issue you should resolve

<issue_title>[android] System.Tests.TimeZoneInfoTests.TestGetSystemTimeZones failure: Assert.DoesNotContain</issue_title>
<issue_description>## Build Information
Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1211662
Build error leg or test failing: System.Tests.TimeZoneInfoTests.TestGetSystemTimeZones
Pull request: #121824

[FAIL] System.Tests.TimeZoneInfoTests.TestGetSystemTimeZones
Assert.DoesNotContain() Failure: Filter matched in collection
                                                                                      ↓ (pos 242)
Collection: [···, (UTC) Coordinated Universal Time, (UTC) Coordinated Universal Time, (UTC) Coordinated Universal Time, (UTC) Coordinated Universal Time, (UTC) Coordinated Universal Time, ···]
   at System.Tests.TimeZoneInfoTests.TestGetSystemTimeZones()
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": ["[FAIL] System.Tests.TimeZoneInfoTests.TestGetSystemTimeZones", "Assert.DoesNotContain() Failure: Filter matched in collection"],
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1211662
Error message validated: [[FAIL] System.Tests.TimeZoneInfoTests.TestGetSystemTimeZones Assert.DoesNotContain() Failure: Filter matched in collection]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 11/25/2025 5:11:04 PM UTC

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix failure in TimeZoneInfoTests.TestGetSystemTimeZones Filter UTC aliases from GetSystemTimeZones to avoid duplicate display names Nov 25, 2025
Copilot AI requested a review from simonrozsival November 25, 2025 17:47
// Skip UTC aliases to avoid duplicate display names in the list.
// UTC is already added to the dictionary at the start, and aliases like
// UCT, Etc/UTC, Zulu, etc. have the same display name as UTC.
if (IsUtcAlias(timeZoneId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsUtcAlias can also be simplified:

private static bool IsUtcAlias(string id) => id[0] switch
{
    'e' or 'E' => string.Equals(id, "Etc/UTC", StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(id, "Etc/UCT", StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(id, "Etc/Universal", StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(id, "Etc/Zulu", StringComparison.OrdinalIgnoreCase),
    'u' or 'U' => string.Equals(id, "UCT", StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(id, "UTC", StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(id, "Universal", StringComparison.OrdinalIgnoreCase),
    'z' or 'Z' => string.Equals(id, "Zulu", StringComparison.OrdinalIgnoreCase),
    _ => false
};

@am11
Copy link
Member

am11 commented Nov 25, 2025

Fixes #121882

It is unrelated?

@simonrozsival
Copy link
Member

It is unrelated?

Yes, copilot got it wrong. Edited.

@simonrozsival simonrozsival changed the title Filter UTC aliases from GetSystemTimeZones to avoid duplicate display names [Android] Filter UTC aliases from GetSystemTimeZones to avoid duplicate display names Nov 26, 2025
@tarekgh
Copy link
Member

tarekgh commented Nov 26, 2025

I don't think this is the right fix. We have the issue #90269 tracking ensuring not returning any duplicates on Android. When this issue get fixed should include UTC alias duplicate too. The change in this PR will add extra overhead for other platforms which is not necessary. I would say disable the failing test on Android for now.

CC @davidnguyen-tech @matouskozak

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

@tarekgh
Copy link
Member

tarekgh commented Nov 26, 2025

@simonrozsival could you please ensure disabling the failing test for Android platform then close #121963 to avoid skipping failures on other platforms? Thanks!

@simonrozsival
Copy link
Member

@tarekgh yes, I will disable the test tomorrow

@jkotas jkotas deleted the copilot/fix-time-zone-tests branch December 4, 2025 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[android] System.Tests.TimeZoneInfoTests.TestGetSystemTimeZones failure: Assert.DoesNotContain

6 participants