Skip to content

Commit 445a232

Browse files
committed
Address PR feedback.
1 parent 64538e3 commit 445a232

File tree

4 files changed

+11
-32
lines changed

4 files changed

+11
-32
lines changed

src/libraries/Microsoft.Bcl.Memory/src/Microsoft.Bcl.Memory.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<DefineConstants>$(DefineConstants);MICROSOFT_BCL_MEMORY</DefineConstants>
77
<IsPackable>true</IsPackable>
8-
<PackageDescription>Provides Base64Url, Utf8, Index and Range types support for .NET Framework and .NET Standard.</PackageDescription>
8+
<PackageDescription>Provides Base64Url, Utf8, Index, and Range types support for .NET Framework and .NET Standard.</PackageDescription>
99
</PropertyGroup>
1010

1111
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->

src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ public int EncodeToUtf8(Span<byte> destination)
781781

782782
public override int GetHashCode() => Value;
783783

784-
#if !MICROSOFT_BCL_MEMORY
784+
#if SYSTEM_PRIVATE_CORELIB
785785
/// <summary>
786786
/// Gets the <see cref="Rune"/> which begins at index <paramref name="index"/> in
787787
/// string <paramref name="input"/>.
@@ -852,7 +852,7 @@ internal static int ReadFirstRuneFromUtf16Buffer(ReadOnlySpan<char> input)
852852
return (int)returnValue;
853853
}
854854

855-
#if !MICROSOFT_BCL_MEMORY
855+
#if SYSTEM_PRIVATE_CORELIB
856856
// returns a negative number on failure
857857
private static int ReadRuneFromString(string input, int index)
858858
{
@@ -1132,7 +1132,7 @@ private static bool TryEncodeToUtf8(Rune value, Span<byte> destination, out int
11321132
return false;
11331133
}
11341134

1135-
#if !MICROSOFT_BCL_MEMORY
1135+
#if SYSTEM_PRIVATE_CORELIB
11361136
/// <summary>
11371137
/// Attempts to get the <see cref="Rune"/> which begins at index <paramref name="index"/> in
11381138
/// string <paramref name="input"/>.

src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@
99

1010
namespace System.Text.Unicode
1111
{
12-
#if SYSTEM_PRIVATE_CORELIB || MICROSOFT_BCL_MEMORY
1312
/// <summary>
14-
/// Provides methods for transcoding between UTF-8 and UTF-16.
13+
/// Provides static methods that convert chunked data between UTF-8 and UTF-16 encodings.
1514
/// </summary>
16-
public
17-
#else
18-
internal
19-
#endif
20-
static class Utf8
15+
public static class Utf8
2116
{
2217
/*
2318
* OperationStatus-based APIs for transcoding of chunked data.

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/Unicode/Utf8Tests.cs

+5-21
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,17 @@ public static byte[] DecodeHex(ReadOnlySpan<char> inputHex)
7575
}
7676
return result;
7777

78-
static int FromHex(char c)
79-
{
80-
if (c >= '0' && c <= '9')
81-
{
82-
return c - '0';
83-
}
84-
else if (c >= 'a' && c <= 'f')
85-
{
86-
return c - 'a' + 10;
87-
}
88-
else
89-
{
90-
return c - 'A' + 10;
91-
}
92-
}
78+
static int FromHex(char c) =>
79+
c >= '0' && c <= '9' ? c - '0' :
80+
c >= 'a' && c <= 'f' ? c - 'a' + 10 :
81+
c - 'A' + 10;
9382
#endif
9483
}
9584

9685
// !! IMPORTANT !!
9786
// Don't delete this implementation, as we use it as a reference to make sure the framework's
9887
// transcoding logic is correct.
99-
#if NET
100-
public
101-
#else
102-
private
103-
#endif
104-
static byte[] ToUtf8(Rune rune)
88+
private static byte[] ToUtf8(Rune rune)
10589
{
10690
Assert.True(Rune.IsValid(rune.Value), $"Rune with value U+{(uint)rune.Value:X4} is not well-formed.");
10791

0 commit comments

Comments
 (0)