@@ -44,8 +44,11 @@ private enum TimeZoneInfoResult
4444 private const int MaxKeyLength = 255 ;
4545
4646 private readonly string _id ;
47+ private bool _displayNameSet ;
4748 private string ? _displayName ;
49+ private bool _standardDisplayNameSet ;
4850 private string ? _standardDisplayName ;
51+ private bool _daylightDisplayNameSet ;
4952 private string ? _daylightDisplayName ;
5053 private readonly TimeSpan _baseUtcOffset ;
5154 private readonly bool _supportsDaylightSavingTime ;
@@ -150,8 +153,11 @@ public string DisplayName
150153 {
151154 get
152155 {
153- if ( _displayName == null )
156+ if ( _displayName == null && ! _displayNameSet )
157+ {
154158 Interlocked . CompareExchange ( ref _displayName , PopulateDisplayName ( ) , null ) ;
159+ _displayNameSet = true ;
160+ }
155161
156162 return _displayName ?? string . Empty ;
157163 }
@@ -161,8 +167,11 @@ public string StandardName
161167 {
162168 get
163169 {
164- if ( _standardDisplayName == null )
170+ if ( _standardDisplayName == null && ! _standardDisplayNameSet )
171+ {
165172 Interlocked . CompareExchange ( ref _standardDisplayName , PopulateStandardDisplayName ( ) , null ) ;
173+ _standardDisplayNameSet = true ;
174+ }
166175
167176 return _standardDisplayName ?? string . Empty ;
168177 }
@@ -172,8 +181,11 @@ public string DaylightName
172181 {
173182 get
174183 {
175- if ( _daylightDisplayName == null )
184+ if ( _daylightDisplayName == null && ! _daylightDisplayNameSet )
185+ {
176186 Interlocked . CompareExchange ( ref _daylightDisplayName , PopulateDaylightDisplayName ( ) , null ) ;
187+ _daylightDisplayNameSet = true ;
188+ }
177189
178190 return _daylightDisplayName ?? string . Empty ;
179191 }
@@ -990,8 +1002,11 @@ private TimeZoneInfo(
9901002 _id = id ;
9911003 _baseUtcOffset = baseUtcOffset ;
9921004 _displayName = displayName ;
1005+ _displayNameSet = true ;
9931006 _standardDisplayName = standardDisplayName ;
1007+ _standardDisplayNameSet = true ;
9941008 _daylightDisplayName = disableDaylightSavingTime ? null : daylightDisplayName ;
1009+ _daylightDisplayNameSet = true ;
9951010 _supportsDaylightSavingTime = adjustmentRulesSupportDst && ! disableDaylightSavingTime ;
9961011 _adjustmentRules = adjustmentRules ;
9971012
@@ -1136,8 +1151,11 @@ private TimeZoneInfo(SerializationInfo info, StreamingContext context)
11361151
11371152 _id = ( string ) info . GetValue ( "Id" , typeof ( string ) ) ! ; // Do not rename (binary serialization)
11381153 _displayName = ( string ? ) info . GetValue ( "DisplayName" , typeof ( string ) ) ; // Do not rename (binary serialization)
1154+ _displayNameSet = true ;
11391155 _standardDisplayName = ( string ? ) info . GetValue ( "StandardName" , typeof ( string ) ) ; // Do not rename (binary serialization)
1156+ _standardDisplayNameSet = true ;
11401157 _daylightDisplayName = ( string ? ) info . GetValue ( "DaylightName" , typeof ( string ) ) ; // Do not rename (binary serialization)
1158+ _daylightDisplayNameSet = true ;
11411159 _baseUtcOffset = ( TimeSpan ) info . GetValue ( "BaseUtcOffset" , typeof ( TimeSpan ) ) ! ; // Do not rename (binary serialization)
11421160 _adjustmentRules = ( AdjustmentRule [ ] ? ) info . GetValue ( "AdjustmentRules" , typeof ( AdjustmentRule [ ] ) ) ; // Do not rename (binary serialization)
11431161 _supportsDaylightSavingTime = ( bool ) info . GetValue ( "SupportsDaylightSavingTime" , typeof ( bool ) ) ! ; // Do not rename (binary serialization)
0 commit comments