Skip to content

Commit afed5fd

Browse files
authored
Enable NumberFormatInfo netstandard 1.7 APIs (dotnet#7659)
* Enable NumberFormatInfo netstandard 1.7 APIs * Remove ComVisible attributes * Remove more ComVisible attributes
1 parent c9f04e2 commit afed5fd

12 files changed

+999
-909
lines changed

src/mscorlib/corefx/SR.cs

+15
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ public static string Argument_InvalidDateTimeStyles
179179
get { return Environment.GetResourceString("Argument_InvalidDateTimeStyles"); }
180180
}
181181

182+
public static string Argument_InvalidDigitSubstitution
183+
{
184+
get { return Environment.GetResourceString("Argument_InvalidDigitSubstitution"); }
185+
}
186+
182187
public static string Argument_InvalidFlag
183188
{
184189
get { return Environment.GetResourceString("Argument_InvalidFlag"); }
@@ -189,6 +194,16 @@ public static string Argument_InvalidGroupSize
189194
get { return Environment.GetResourceString("Argument_InvalidGroupSize"); }
190195
}
191196

197+
public static string Argument_InvalidNativeDigitCount
198+
{
199+
get { return Environment.GetResourceString("Argument_InvalidNativeDigitCount"); }
200+
}
201+
202+
public static string Argument_InvalidNativeDigitValue
203+
{
204+
get { return Environment.GetResourceString("Argument_InvalidNativeDigitValue"); }
205+
}
206+
192207
public static string Argument_InvalidNeutralRegionName
193208
{
194209
get { return Environment.GetResourceString("Argument_InvalidNeutralRegionName"); }

src/mscorlib/corefx/System/Globalization/CultureData.Unix.cs

+6
Original file line numberDiff line numberDiff line change
@@ -339,5 +339,11 @@ private static int GetGeoId(string cultureName)
339339
int geoId = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.GeoId);
340340
return geoId == -1 ? CultureData.Invariant.IGEOID : geoId;
341341
}
342+
343+
private static int GetDigitSubstitution(string cultureName)
344+
{
345+
int digitSubstitution = LocaleData.GetLocaleDataNumericPart(cultureName, LocaleDataParts.DigitSubstitution);
346+
return digitSubstitution == -1 ? (int) DigitShapes.None : digitSubstitution;
347+
}
342348
}
343349
}

src/mscorlib/corefx/System/Globalization/CultureData.Windows.cs

+5
Original file line numberDiff line numberDiff line change
@@ -592,5 +592,10 @@ private static int GetGeoId(string cultureName)
592592
{
593593
throw new NotImplementedException();
594594
}
595+
596+
private static int GetDigitSubstitution(string cultureName)
597+
{
598+
throw new NotImplementedException();
599+
}
595600
}
596601
}

src/mscorlib/corefx/System/Globalization/CultureData.cs

+2-15
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ internal partial class CultureData
9090
// Numbers
9191
private String _sPositiveSign; // (user can override) positive sign
9292
private String _sNegativeSign; // (user can override) negative sign
93-
private String[] _saNativeDigits; // (user can override) native characters for digits 0-9
9493
// (nfi populates these 5, don't have to be = undef)
9594
private int _iDigits; // (user can override) number of fractional digits
9695
private int _iNegativeNumber; // (user can override) negative number format
@@ -446,7 +445,6 @@ internal static CultureData Invariant
446445
// Numbers
447446
invariant._sPositiveSign = "+"; // positive sign
448447
invariant._sNegativeSign = "-"; // negative sign
449-
invariant._saNativeDigits = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; // native characters for digits 0-9
450448
invariant._iDigits = 2; // number of fractional digits
451449
invariant._iNegativeNumber = 1; // negative number format
452450
invariant._waGrouping = new int[] { 3 }; // grouping of digits
@@ -1055,18 +1053,6 @@ internal String SISO3166CTRYNAME2
10551053
}
10561054
}
10571055

1058-
/////////////
1059-
// Numbers //
1060-
////////////
1061-
1062-
// internal String sPositiveSign ; // (user can override) positive sign
1063-
// internal String sNegativeSign ; // (user can override) negative sign
1064-
// internal String[] saNativeDigits ; // (user can override) native characters for digits 0-9
1065-
// internal int iDigits ; // (user can override) number of fractional digits
1066-
// internal int iNegativeNumber ; // (user can override) negative number format
1067-
1068-
1069-
10701056
// (user can override) grouping of digits
10711057
internal int[] WAGROUPING
10721058
{
@@ -2101,7 +2087,6 @@ internal void GetNFIValues(NumberFormatInfo nfi)
21012087
if (this.IsInvariantCulture)
21022088
{
21032089
// FUTURE: NumberFormatInfo already has default values for many of these fields. Can we not do this?
2104-
// if we do need to do this, then why don't we set nfi.nativeDigits in this case?
21052090
nfi.positiveSign = _sPositiveSign;
21062091
nfi.negativeSign = _sNegativeSign;
21072092

@@ -2144,6 +2129,8 @@ internal void GetNFIValues(NumberFormatInfo nfi)
21442129
{
21452130
nfi.nativeDigits[i] = new string(digits[i], 1);
21462131
}
2132+
2133+
nfi.digitSubstitution = GetDigitSubstitution(_sRealName);
21472134
}
21482135

21492136
//
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
//
6+
// The enumeration constants used in NumberFormatInfo.DigitSubstitution.
7+
//
8+
namespace System.Globalization
9+
{
10+
[Serializable]
11+
public enum DigitShapes : int
12+
{
13+
Context = 0x0000, // The shape depends on the previous text in the same output.
14+
None = 0x0001, // Gives full Unicode compatibility.
15+
NativeNational = 0x0002 // National shapes
16+
}
17+
}

0 commit comments

Comments
 (0)