Skip to content

Commit 16e325d

Browse files
Delete checked-in Unicode data files in favor of runtime-assets package (dotnet#1743)
IDNA files (in System.Globalization.Extensions.Tests) not yet deleted; will tackle this later
1 parent 6ea79a1 commit 16e325d

File tree

18 files changed

+61
-122375
lines changed

18 files changed

+61
-122375
lines changed

src/libraries/Common/tests/CoreFx.Private.TestUtilities.Unicode/System/Text/Unicode/UnicodeData.cs

+26-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Globalization;
56
using System.Threading;
67

78
namespace System.Text.Unicode
@@ -13,7 +14,7 @@ public static class UnicodeData
1314

1415
public static CodePoint GetData(int codePoint)
1516
{
16-
if ((uint)codePoint >= _codePointData.Length)
17+
if ((uint)codePoint >= (uint)_codePointData.Length)
1718
{
1819
throw new ArgumentOutOfRangeException(
1920
message: FormattableString.Invariant($"Value U+{(uint)codePoint:X4} is not a valid code point."),
@@ -36,5 +37,29 @@ public static CodePoint GetData(int codePoint)
3637
public static CodePoint GetData(uint codePoint) => GetData((int)codePoint);
3738

3839
public static CodePoint GetData(Rune rune) => GetData(rune.Value);
40+
41+
/*
42+
* Helper methods
43+
*/
44+
45+
public static UnicodeCategory GetUnicodeCategory(int codePoint) => GetData(codePoint).GeneralCategory;
46+
47+
public static bool IsLetter(int codePoint)
48+
{
49+
switch (GetUnicodeCategory(codePoint))
50+
{
51+
case UnicodeCategory.UppercaseLetter:
52+
case UnicodeCategory.LowercaseLetter:
53+
case UnicodeCategory.TitlecaseLetter:
54+
case UnicodeCategory.ModifierLetter:
55+
case UnicodeCategory.OtherLetter:
56+
return true;
57+
58+
default:
59+
return false;
60+
}
61+
}
62+
63+
public static bool IsWhiteSpace(int codePoint) => (GetData(codePoint).Flags & CodePointFlags.White_Space) != 0;
3964
}
4065
}

src/libraries/Common/tests/Data/CaseFolding-12.1.0.txt

-1,581
This file was deleted.

src/libraries/Common/tests/Data/PropList-12.1.0.txt

-1,666
This file was deleted.

src/libraries/Common/tests/Data/UnicodeData.11.0.txt

-32,292
This file was deleted.

src/libraries/Common/tests/Data/UnicodeData.12.1.txt

-32,841
This file was deleted.

src/libraries/Common/tests/Data/UnicodeData.8.0.txt

-29,215
This file was deleted.

src/libraries/Common/tests/Data/UnicodeData63.txt

-24,434
This file was deleted.

src/libraries/Common/tests/Data/UnicodeReadme.txt

-4
This file was deleted.

src/libraries/System.Globalization/tests/System.Globalization.Tests.csproj

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TestRuntime>true</TestRuntime>
55
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
66
<Configurations>$(NetCoreAppCurrent)-Debug;$(NetCoreAppCurrent)-Release</Configurations>
7+
<UnicodeUcdVersion>12.1</UnicodeUcdVersion>
78
</PropertyGroup>
89
<ItemGroup>
910
<Compile Include="CompareInfo\CompareInfoTests.cs" />
@@ -117,13 +118,13 @@
117118
</ItemGroup>
118119
<ItemGroup>
119120
<PackageReference Include="System.Private.Runtime.UnicodeData" Version="$(SystemPrivateRuntimeUnicodeDataVersion)" ExcludeAssets="contentFiles" GeneratePathProperty="true" />
120-
<EmbeddedResource Include="$(PkgSystem_Private_Runtime_UnicodeData)\contentFiles\any\any\12.1.0\ucd\UnicodeData.txt">
121-
<Link>CharUnicodeInfo\UnicodeData.12.1.txt</Link>
122-
<LogicalName>UnicodeData.12.1.txt</LogicalName>
121+
<EmbeddedResource Include="$(PkgSystem_Private_Runtime_UnicodeData)\contentFiles\any\any\$(UnicodeUcdVersion).0\ucd\UnicodeData.txt">
122+
<Link>CharUnicodeInfo\UnicodeData.$(UnicodeUcdVersion).txt</Link>
123+
<LogicalName>UnicodeData.txt</LogicalName>
123124
</EmbeddedResource>
124-
<EmbeddedResource Include="$(PkgSystem_Private_Runtime_UnicodeData)\contentFiles\any\any\12.1.0\ucd\auxiliary\GraphemeBreakTest.txt">
125-
<Link>CharUnicodeInfo\GraphemeBreakTest-12.1.0.txt</Link>
126-
<LogicalName>GraphemeBreakTest-12.1.0.txt</LogicalName>
125+
<EmbeddedResource Include="$(PkgSystem_Private_Runtime_UnicodeData)\contentFiles\any\any\$(UnicodeUcdVersion).0\ucd\auxiliary\GraphemeBreakTest.txt">
126+
<Link>CharUnicodeInfo\GraphemeBreakTest-$(UnicodeUcdVersion).0.txt</Link>
127+
<LogicalName>GraphemeBreakTest.txt</LogicalName>
127128
</EmbeddedResource>
128129
</ItemGroup>
129130
<ItemGroup>

src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTestData.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static class CharUnicodeInfoTestData
1313
private static readonly Lazy<List<CharUnicodeInfoTestCase>> s_testCases = new Lazy<List<CharUnicodeInfoTestCase>>(() =>
1414
{
1515
List<CharUnicodeInfoTestCase> testCases = new List<CharUnicodeInfoTestCase>();
16-
string fileName = "UnicodeData.12.1.txt";
16+
string fileName = "UnicodeData.txt";
1717
Stream stream = typeof(CharUnicodeInfoTestData).GetTypeInfo().Assembly.GetManifestResourceStream(fileName);
1818
using (StreamReader reader = new StreamReader(stream))
1919
{

src/libraries/System.Globalization/tests/System/Globalization/GraphemeBreakTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void ReplacementCharHasTypeOther()
9494

9595
private static IEnumerable<(Rune[][] clusters, string line)> GetGraphemeBreakTestData()
9696
{
97-
using Stream stream = typeof(GraphemeBreakTest).Assembly.GetManifestResourceStream("GraphemeBreakTest-12.1.0.txt");
97+
using Stream stream = typeof(GraphemeBreakTest).Assembly.GetManifestResourceStream("GraphemeBreakTest.txt");
9898
using StreamReader reader = new StreamReader(stream);
9999

100100
string line;

src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj

+3-15
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@
252252
<Compile Include="System\Text\ASCIIUtilityTests.cs" />
253253
<Compile Include="System\Text\RuneTests.cs" />
254254
<Compile Include="System\Text\RuneTests.TestData.cs" />
255-
<Compile Include="System\Text\Unicode\UnicodeData.cs" />
256255
<Compile Include="System\Text\Unicode\Utf16UtilityTests.ValidateChars.cs" />
257256
<Compile Include="System\Text\Unicode\Utf8Tests.cs" />
258257
<Compile Include="System\Text\Unicode\Utf8UtilityTests.ValidateBytes.cs" />
@@ -276,24 +275,13 @@
276275
<Link>Common\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs</Link>
277276
</Compile>
278277
</ItemGroup>
279-
<ItemGroup>
280-
<EmbeddedResource Include="$(CommonTestPath)Data\UnicodeData.12.1.txt">
281-
<Link>System\Text\Unicode\UnicodeData.12.1.txt</Link>
282-
<LogicalName>UnicodeData.12.1.txt</LogicalName>
283-
</EmbeddedResource>
284-
<EmbeddedResource Include="$(CommonTestPath)Data\CaseFolding-12.1.0.txt">
285-
<Link>System\Text\Unicode\CaseFolding-12.1.0.txt</Link>
286-
<LogicalName>CaseFolding-12.1.0.txt</LogicalName>
287-
</EmbeddedResource>
288-
<EmbeddedResource Include="$(CommonTestPath)Data\PropList-12.1.0.txt">
289-
<Link>System\Text\Unicode\PropList-12.1.0.txt</Link>
290-
<LogicalName>PropList-12.1.0.txt</LogicalName>
291-
</EmbeddedResource>
292-
</ItemGroup>
293278
<ItemGroup>
294279
<ProjectReference Include="TestLoadAssembly\TestLoadAssembly.csproj" />
295280
<ProjectReference Include="TestCollectibleAssembly\TestCollectibleAssembly.csproj" />
296281
<ProjectReference Include="TestModule\System.Reflection.TestModule.ilproj" />
297282
<ProjectReference Include="TestStructs\System.TestStructs.ilproj" />
298283
</ItemGroup>
284+
<ItemGroup>
285+
<ProjectReference Include="$(CommonTestPath)CoreFx.Private.TestUtilities.Unicode\CoreFx.Private.TestUtilities.Unicode.csproj" />
286+
</ItemGroup>
299287
</Project>

src/libraries/System.Runtime/tests/System/CharTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Collections.Generic;
66
using System.Globalization;
77
using System.Text;
8-
using System.Text.Unicode.Tests;
8+
using System.Text.Unicode;
99
using Xunit;
1010
using Xunit.Sdk;
1111

@@ -1116,7 +1116,7 @@ public static void GetUnicodeCategory_Char_AllInputs()
11161116
// This tests calls char.GetUnicodeCategory for every possible input, ensuring that
11171117
// the runtime agrees with the data in the core Unicode files.
11181118

1119-
for (uint i = 0; i <= char.MaxValue; i++)
1119+
for (int i = 0; i <= char.MaxValue; i++)
11201120
{
11211121
UnicodeCategory expected;
11221122

@@ -1250,7 +1250,7 @@ public static void IsWhiteSpace_Char_AllInputs()
12501250
// This tests calls char.IsWhiteSpace for every possible input, ensuring that
12511251
// the runtime agrees with the data in the core Unicode files.
12521252

1253-
for (uint i = 0; i <= char.MaxValue; i++)
1253+
for (int i = 0; i <= char.MaxValue; i++)
12541254
{
12551255
if (UnicodeData.IsWhiteSpace(i) != char.IsWhiteSpace((char)i))
12561256
{

src/libraries/System.Runtime/tests/System/Text/RuneTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using System.Buffers;
66
using System.Globalization;
7-
using System.Text.Unicode.Tests;
7+
using System.Text.Unicode;
88
using Xunit;
99
using Xunit.Sdk;
1010

@@ -350,11 +350,11 @@ public static void GetUnicodeCategory_AllInputs()
350350

351351
foreach (Rune rune in AllRunes())
352352
{
353-
if (UnicodeData.GetUnicodeCategory((uint)rune.Value) != Rune.GetUnicodeCategory(rune))
353+
if (UnicodeData.GetUnicodeCategory(rune.Value) != Rune.GetUnicodeCategory(rune))
354354
{
355355
// We'll build up the exception message ourselves so the dev knows what code point failed.
356356
throw new AssertActualExpectedException(
357-
expected: UnicodeData.GetUnicodeCategory((uint)rune.Value),
357+
expected: UnicodeData.GetUnicodeCategory(rune.Value),
358358
actual: Rune.GetUnicodeCategory(rune),
359359
userMessage: FormattableString.Invariant($@"Rune.GetUnicodeCategory(U+{rune.Value:X4}) returned wrong value."));
360360
}
@@ -455,7 +455,7 @@ public static void IsWhiteSpace_AllInputs()
455455

456456
foreach (Rune rune in AllRunes())
457457
{
458-
Assert.Equal(UnicodeData.IsWhiteSpace((uint)rune.Value), Rune.IsWhiteSpace(rune));
458+
Assert.Equal(UnicodeData.IsWhiteSpace(rune.Value), Rune.IsWhiteSpace(rune));
459459
}
460460
}
461461

0 commit comments

Comments
 (0)