@@ -44,8 +44,11 @@ private enum TimeZoneInfoResult
44
44
private const int MaxKeyLength = 255 ;
45
45
46
46
private readonly string _id ;
47
+ private bool _displayNameSet ;
47
48
private string ? _displayName ;
49
+ private bool _standardDisplayNameSet ;
48
50
private string ? _standardDisplayName ;
51
+ private bool _daylightDisplayNameSet ;
49
52
private string ? _daylightDisplayName ;
50
53
private readonly TimeSpan _baseUtcOffset ;
51
54
private readonly bool _supportsDaylightSavingTime ;
@@ -150,8 +153,11 @@ public string DisplayName
150
153
{
151
154
get
152
155
{
153
- if ( _displayName == null )
156
+ if ( _displayName == null && ! _displayNameSet )
157
+ {
154
158
Interlocked . CompareExchange ( ref _displayName , PopulateDisplayName ( ) , null ) ;
159
+ _displayNameSet = true ;
160
+ }
155
161
156
162
return _displayName ?? string . Empty ;
157
163
}
@@ -161,8 +167,11 @@ public string StandardName
161
167
{
162
168
get
163
169
{
164
- if ( _standardDisplayName == null )
170
+ if ( _standardDisplayName == null && ! _standardDisplayNameSet )
171
+ {
165
172
Interlocked . CompareExchange ( ref _standardDisplayName , PopulateStandardDisplayName ( ) , null ) ;
173
+ _standardDisplayNameSet = true ;
174
+ }
166
175
167
176
return _standardDisplayName ?? string . Empty ;
168
177
}
@@ -172,8 +181,11 @@ public string DaylightName
172
181
{
173
182
get
174
183
{
175
- if ( _daylightDisplayName == null )
184
+ if ( _daylightDisplayName == null && ! _daylightDisplayNameSet )
185
+ {
176
186
Interlocked . CompareExchange ( ref _daylightDisplayName , PopulateDaylightDisplayName ( ) , null ) ;
187
+ _daylightDisplayNameSet = true ;
188
+ }
177
189
178
190
return _daylightDisplayName ?? string . Empty ;
179
191
}
@@ -990,8 +1002,11 @@ private TimeZoneInfo(
990
1002
_id = id ;
991
1003
_baseUtcOffset = baseUtcOffset ;
992
1004
_displayName = displayName ;
1005
+ _displayNameSet = true ;
993
1006
_standardDisplayName = standardDisplayName ;
1007
+ _standardDisplayNameSet = true ;
994
1008
_daylightDisplayName = disableDaylightSavingTime ? null : daylightDisplayName ;
1009
+ _daylightDisplayNameSet = true ;
995
1010
_supportsDaylightSavingTime = adjustmentRulesSupportDst && ! disableDaylightSavingTime ;
996
1011
_adjustmentRules = adjustmentRules ;
997
1012
@@ -1136,8 +1151,11 @@ private TimeZoneInfo(SerializationInfo info, StreamingContext context)
1136
1151
1137
1152
_id = ( string ) info . GetValue ( "Id" , typeof ( string ) ) ! ; // Do not rename (binary serialization)
1138
1153
_displayName = ( string ? ) info . GetValue ( "DisplayName" , typeof ( string ) ) ; // Do not rename (binary serialization)
1154
+ _displayNameSet = true ;
1139
1155
_standardDisplayName = ( string ? ) info . GetValue ( "StandardName" , typeof ( string ) ) ; // Do not rename (binary serialization)
1156
+ _standardDisplayNameSet = true ;
1140
1157
_daylightDisplayName = ( string ? ) info . GetValue ( "DaylightName" , typeof ( string ) ) ; // Do not rename (binary serialization)
1158
+ _daylightDisplayNameSet = true ;
1141
1159
_baseUtcOffset = ( TimeSpan ) info . GetValue ( "BaseUtcOffset" , typeof ( TimeSpan ) ) ! ; // Do not rename (binary serialization)
1142
1160
_adjustmentRules = ( AdjustmentRule [ ] ? ) info . GetValue ( "AdjustmentRules" , typeof ( AdjustmentRule [ ] ) ) ; // Do not rename (binary serialization)
1143
1161
_supportsDaylightSavingTime = ( bool ) info . GetValue ( "SupportsDaylightSavingTime" , typeof ( bool ) ) ! ; // Do not rename (binary serialization)
0 commit comments