Skip to content

Commit bf6f989

Browse files
committed
Fix compile errors.
1 parent 79ee05d commit bf6f989

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.1;netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
@@ -29,8 +29,10 @@
2929

3030
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
3131
<Compile Include="Polyfills\System.Numerics.BitOperations.netstandard20.cs" />
32+
<Compile Include="System\ThrowHelper.cs" />
3233
<Compile Include="$(CoreLibSharedDir)System\Text\Ascii.Utility.cs" Link="System\Text\Ascii.Utility.cs" />
3334
<Compile Include="$(CoreLibSharedDir)System\Text\Ascii.Utility.Helpers.cs" Link="System\Text\Ascii.Utility.Helpers.cs" />
35+
<Compile Include="$(CoreLibSharedDir)System\Text\Rune.cs" Link="System\Text\Rune.cs" />
3436
<Compile Include="$(CoreLibSharedDir)System\Text\UnicodeDebug.cs" Link="System\Text\UnicodeDebug.cs" />
3537
<Compile Include="$(CoreLibSharedDir)System\Text\UnicodeUtility.cs" Link="System\Text\UnicodeUtility.cs" />
3638
<Compile Include="$(CoreLibSharedDir)System\Text\Unicode\Utf16Utility.cs" Link="System\Text\Unicode\Utf16Utility.cs" />
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
4+
using System.Diagnostics;
5+
using System.Diagnostics.CodeAnalysis;
6+
7+
namespace System
8+
{
9+
internal static class ThrowHelper
10+
{
11+
[DoesNotReturn]
12+
internal static void ThrowArgumentException_DestinationTooShort()
13+
{
14+
throw new ArgumentException(SR.Argument_DestinationTooShort, "destination");
15+
}
16+
17+
[DoesNotReturn]
18+
internal static void ThrowArgumentNullException(ExceptionArgument argument)
19+
{
20+
throw new ArgumentNullException(GetArgumentName(argument));
21+
}
22+
23+
[DoesNotReturn]
24+
internal static void ThrowArgumentOutOfRangeException(ExceptionArgument argument)
25+
{
26+
throw new ArgumentOutOfRangeException(GetArgumentName(argument));
27+
}
28+
29+
private static string GetArgumentName(ExceptionArgument argument)
30+
{
31+
switch (argument)
32+
{
33+
case ExceptionArgument.ch:
34+
return nameof(ExceptionArgument.ch);
35+
case ExceptionArgument.culture:
36+
return nameof(ExceptionArgument.culture);
37+
case ExceptionArgument.index:
38+
return nameof(ExceptionArgument.index);
39+
case ExceptionArgument.input:
40+
return nameof(ExceptionArgument.input);
41+
case ExceptionArgument.value:
42+
return nameof(ExceptionArgument.value);
43+
default:
44+
Debug.Fail("The enum value is not defined, please check the ExceptionArgument Enum.");
45+
return "";
46+
47+
}
48+
}
49+
}
50+
51+
//
52+
// The convention for this enum is using the argument name as the enum name
53+
//
54+
internal enum ExceptionArgument
55+
{
56+
ch,
57+
culture,
58+
index,
59+
input,
60+
value,
61+
}
62+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ public int EncodeToUtf8(Span<byte> destination)
781781

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

784+
#if !MICROSOFT_BCL_MEMORY
784785
/// <summary>
785786
/// Gets the <see cref="Rune"/> which begins at index <paramref name="index"/> in
786787
/// string <paramref name="input"/>.
@@ -799,6 +800,7 @@ public static Rune GetRuneAt(string input, int index)
799800

800801
return UnsafeCreate((uint)runeValue);
801802
}
803+
#endif
802804

803805
/// <summary>
804806
/// Returns <see langword="true"/> iff <paramref name="value"/> is a valid Unicode scalar
@@ -850,6 +852,7 @@ internal static int ReadFirstRuneFromUtf16Buffer(ReadOnlySpan<char> input)
850852
return (int)returnValue;
851853
}
852854

855+
#if !MICROSOFT_BCL_MEMORY
853856
// returns a negative number on failure
854857
private static int ReadRuneFromString(string input, int index)
855858
{
@@ -897,6 +900,7 @@ private static int ReadRuneFromString(string input, int index)
897900

898901
return (int)returnValue;
899902
}
903+
#endif
900904

901905
/// <summary>
902906
/// Returns a <see cref="string"/> representation of this <see cref="Rune"/> instance.
@@ -1128,6 +1132,7 @@ private static bool TryEncodeToUtf8(Rune value, Span<byte> destination, out int
11281132
return false;
11291133
}
11301134

1135+
#if !MICROSOFT_BCL_MEMORY
11311136
/// <summary>
11321137
/// Attempts to get the <see cref="Rune"/> which begins at index <paramref name="index"/> in
11331138
/// string <paramref name="input"/>.
@@ -1151,6 +1156,7 @@ public static bool TryGetRuneAt(string input, int index, out Rune value)
11511156
return false;
11521157
}
11531158
}
1159+
#endif
11541160

11551161
// Allows constructing a Unicode scalar value from an arbitrary 32-bit integer without
11561162
// validation. It is the caller's responsibility to have performed manual validation

0 commit comments

Comments
 (0)