[release/8.0-staging] Correct time zone name creation when generated lazily. #95364
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #95213
Backport of #95304 to release/8.0-staging
/cc @tarekgh
Customer Impact
Applications running on Linux/Mac that create
TimeZoneInfo
objects using Windows zone IDs (e.g.,Pacific Standard Time
) and subsequently request the time zone's Standard, Daylight, or Display name may receive empty strings instead of the expected descriptive time zone names. This issue is a regression in .NET 8.0 introduced by the optimization change outlined in #88368 that aimed to enhance the creation time of the time zone object by deferring the initialization of zone names until they are specifically requested, as opposed to proactively generating the names during the initial creation. Applications and users rely on accurate time zone names, particularly in UI scenarios where the names are displayed.Testing
I have included additional test cases to cover the specific scenario of concern, ensuring that the code passes all regression tests. This change has been manually tested on Linux and Windows too.
Risk
The changes made are limited and scoped to the initialization of time zone names, without altering any other logic.
IMPORTANT: If this backport is for a servicing release, please verify that:
The PR target branch is
release/X.0-staging
, notrelease/X.0
.If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.