summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs')
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs
index 03bed85c00..30471095f0 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
namespace System.Globalization
@@ -21,7 +22,7 @@ namespace System.Globalization
private readonly CultureData _cultureData;
// The RegionInfo for our current region
- internal static volatile RegionInfo s_currentRegionInfo;
+ internal static volatile RegionInfo? s_currentRegionInfo;
public RegionInfo(string name)
{
@@ -37,11 +38,8 @@ namespace System.Globalization
}
// For CoreCLR we only want the region names that are full culture names
- _cultureData = CultureData.GetCultureDataForRegion(name, true);
- if (_cultureData == null)
- {
+ _cultureData = CultureData.GetCultureDataForRegion(name, true) ??
throw new ArgumentException(SR.Format(SR.Argument_InvalidCultureName, name), nameof(name));
- }
// Not supposed to be neutral
if (_cultureData.IsNeutralCulture)
@@ -49,7 +47,7 @@ namespace System.Globalization
throw new ArgumentException(SR.Format(SR.Argument_InvalidNeutralRegionName, name), nameof(name));
}
- SetName(name);
+ _name = _cultureData.RegionName;
}
public RegionInfo(int culture)
@@ -88,12 +86,6 @@ namespace System.Globalization
_name = _cultureData.RegionName;
}
- private void SetName(string name)
- {
- // Use the name of the region we found
- _name = _cultureData.RegionName;
- }
-
/// <summary>
/// This instance provides methods based on the current user settings.
/// These settings are volatile and may change over the lifetime of the
@@ -102,7 +94,7 @@ namespace System.Globalization
{
get
{
- RegionInfo temp = s_currentRegionInfo;
+ RegionInfo? temp = s_currentRegionInfo;
if (temp == null)
{
temp = new RegionInfo(CultureInfo.CurrentCulture._cultureData);
@@ -194,7 +186,7 @@ namespace System.Globalization
/// RegionInfos are considered equal if and only if they have the same name
/// (ie: en-US)
/// </summary>
- public override bool Equals(object value)
+ public override bool Equals(object? value)
{
return value is RegionInfo otherRegion
&& Name.Equals(otherRegion.Name);