Skip to content

Commit a47ea8c

Browse files
committed
Substitute null name properties with empty string in default constructor
1 parent 3ffa389 commit a47ea8c

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,24 @@ public AdjustmentRule[] GetAdjustmentRules()
9191
private static string? PopulateDisplayName()
9292
{
9393
// Keep window's implementation to populate via constructor
94+
// This should not be reached
95+
Debug.Assert(false);
9496
return null;
9597
}
9698

9799
private static string? PopulateStandardDisplayName()
98100
{
99101
// Keep window's implementation to populate via constructor
102+
// This should not be reached
103+
Debug.Assert(false);
100104
return null;
101105
}
102106

103107
private static string? PopulateDaylightDisplayName()
104108
{
105109
// Keep window's implementation to populate via constructor
110+
// This should not be reached
111+
Debug.Assert(false);
106112
return null;
107113
}
108114

@@ -918,9 +924,9 @@ private static TimeZoneInfoResult TryGetTimeZoneFromLocalMachine(string id, out
918924
value = new TimeZoneInfo(
919925
id,
920926
new TimeSpan(0, -(defaultTimeZoneInformation.Bias), 0),
921-
displayName,
922-
standardName,
923-
daylightName,
927+
displayName ?? string.Empty,
928+
standardName ?? string.Empty,
929+
daylightName ?? string.Empty,
924930
adjustmentRules,
925931
disableDaylightSavingTime: false);
926932

src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,9 @@ private TimeZoneInfo(
989989

990990
_id = id;
991991
_baseUtcOffset = baseUtcOffset;
992-
_displayName = displayName;
993-
_standardDisplayName = standardDisplayName;
994-
_daylightDisplayName = disableDaylightSavingTime ? null : daylightDisplayName;
992+
_displayName = displayName ?? string.Empty;
993+
_standardDisplayName = standardDisplayName ?? string.Empty;
994+
_daylightDisplayName = disableDaylightSavingTime ? string.Empty : daylightDisplayName ?? string.Empty;
995995
_supportsDaylightSavingTime = adjustmentRulesSupportDst && !disableDaylightSavingTime;
996996
_adjustmentRules = adjustmentRules;
997997

@@ -1012,9 +1012,9 @@ public static TimeZoneInfo CreateCustomTimeZone(
10121012
return new TimeZoneInfo(
10131013
id,
10141014
baseUtcOffset,
1015-
displayName ?? string.Empty,
1016-
standardDisplayName ?? string.Empty,
1017-
standardDisplayName ?? string.Empty,
1015+
displayName,
1016+
standardDisplayName,
1017+
standardDisplayName,
10181018
adjustmentRules: null,
10191019
disableDaylightSavingTime: false,
10201020
hasIanaId);
@@ -1034,9 +1034,9 @@ public static TimeZoneInfo CreateCustomTimeZone(
10341034
return CreateCustomTimeZone(
10351035
id,
10361036
baseUtcOffset,
1037-
displayName ?? string.Empty,
1038-
standardDisplayName ?? string.Empty,
1039-
daylightDisplayName ?? string.Empty,
1037+
displayName,
1038+
standardDisplayName,
1039+
daylightDisplayName,
10401040
adjustmentRules,
10411041
disableDaylightSavingTime: false);
10421042
}
@@ -1063,9 +1063,9 @@ public static TimeZoneInfo CreateCustomTimeZone(
10631063
return new TimeZoneInfo(
10641064
id,
10651065
baseUtcOffset,
1066-
displayName ?? string.Empty,
1067-
standardDisplayName ?? string.Empty,
1068-
daylightDisplayName ?? string.Empty,
1066+
displayName,
1067+
standardDisplayName,
1068+
daylightDisplayName,
10691069
adjustmentRules,
10701070
disableDaylightSavingTime,
10711071
hasIanaId);

0 commit comments

Comments
 (0)