Skip to content

Commit be80737

Browse files
authored
Revert "Add methods from dotnet#27912 (Flow System.Text.Rune through more APIs) (#1…" (dotnet#120138)
This reverts commit 1b4eff2. Fixes dotnet#120137
1 parent f76cbfd commit be80737

File tree

18 files changed

+6
-1602
lines changed

18 files changed

+6
-1602
lines changed

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,6 @@
12171217
<Compile Include="$(MSBuildThisFileDirectory)System\Text\SpanRuneEnumerator.cs" />
12181218
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilder.cs" />
12191219
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilder.Debug.cs" Condition="'$(Configuration)' == 'Debug'" />
1220-
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilderRuneEnumerator.cs" />
12211220
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringRuneEnumerator.cs" />
12221221
<Compile Include="$(MSBuildThisFileDirectory)System\Text\TranscodingStream.cs" />
12231222
<Compile Include="$(MSBuildThisFileDirectory)System\Text\TrimType.cs" />

src/libraries/System.Private.CoreLib/src/System/Char.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,6 @@ public bool Equals(char obj)
129129
return m_value == obj;
130130
}
131131

132-
internal bool Equals(char right, StringComparison comparisonType)
133-
{
134-
switch (comparisonType)
135-
{
136-
case StringComparison.Ordinal:
137-
return Equals(right);
138-
default:
139-
ReadOnlySpan<char> leftCharsSlice = [this];
140-
ReadOnlySpan<char> rightCharsSlice = [right];
141-
return leftCharsSlice.Equals(rightCharsSlice, comparisonType);
142-
}
143-
}
144-
145132
// Compares this object to another object, returning an integer that
146133
// indicates the relationship.
147134
// Returns a value less than zero if this object

src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.cs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,6 @@ public string ToLower(string str)
180180
return ChangeCaseCommon<ToLowerConversion>(str);
181181
}
182182

183-
internal void ToLower(ReadOnlySpan<char> source, Span<char> destination)
184-
{
185-
if (GlobalizationMode.Invariant)
186-
{
187-
InvariantModeCasing.ToLower(source, destination);
188-
return;
189-
}
190-
191-
ChangeCaseCommon<ToLowerConversion>(source, destination);
192-
}
193-
194183
private unsafe char ChangeCase(char c, bool toUpper)
195184
{
196185
Debug.Assert(!GlobalizationMode.Invariant);
@@ -462,17 +451,6 @@ public string ToUpper(string str)
462451
return ChangeCaseCommon<ToUpperConversion>(str);
463452
}
464453

465-
internal void ToUpper(ReadOnlySpan<char> source, Span<char> destination)
466-
{
467-
if (GlobalizationMode.Invariant)
468-
{
469-
InvariantModeCasing.ToUpper(source, destination);
470-
return;
471-
}
472-
473-
ChangeCaseCommon<ToUpperConversion>(source, destination);
474-
}
475-
476454
[MethodImpl(MethodImplOptions.AggressiveInlining)]
477455
internal static char ToUpperAsciiInvariant(char c)
478456
{
@@ -483,50 +461,6 @@ internal static char ToUpperAsciiInvariant(char c)
483461
return c;
484462
}
485463

486-
/// <summary>
487-
/// Converts the specified rune to lowercase.
488-
/// </summary>
489-
/// <param name="value">The rune to convert to lowercase.</param>
490-
/// <returns>The specified rune converted to lowercase.</returns>
491-
public Rune ToLower(Rune value)
492-
{
493-
// Convert rune to span
494-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
495-
496-
// Change span to lower and convert to rune
497-
if (valueChars.Length == 2)
498-
{
499-
Span<char> lowerChars = stackalloc char[2];
500-
ToLower(valueChars, lowerChars);
501-
return new Rune(lowerChars[0], lowerChars[1]);
502-
}
503-
504-
char lowerChar = ToLower(valueChars[0]);
505-
return new Rune(lowerChar);
506-
}
507-
508-
/// <summary>
509-
/// Converts the specified rune to uppercase.
510-
/// </summary>
511-
/// <param name="value">The rune to convert to uppercase.</param>
512-
/// <returns>The specified rune converted to uppercase.</returns>
513-
public Rune ToUpper(Rune value)
514-
{
515-
// Convert rune to span
516-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
517-
518-
// Change span to upper and convert to rune
519-
if (valueChars.Length == 2)
520-
{
521-
Span<char> upperChars = stackalloc char[2];
522-
ToUpper(valueChars, upperChars);
523-
return new Rune(upperChars[0], upperChars[1]);
524-
}
525-
526-
char upperChar = ToUpper(valueChars[0]);
527-
return new Rune(upperChar);
528-
}
529-
530464
private bool IsAsciiCasingSameAsInvariant
531465
{
532466
[MethodImpl(MethodImplOptions.AggressiveInlining)]

src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,6 @@ public virtual void Write(char value)
125125
{
126126
}
127127

128-
/// <summary>
129-
/// Writes a rune to the text stream.
130-
/// </summary>
131-
/// <param name="value">The rune to write to the text stream.</param>
132-
public virtual void Write(Rune value)
133-
{
134-
// Convert value to span
135-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
136-
137-
// Write span
138-
Write(valueChars[0]);
139-
if (valueChars.Length > 1)
140-
{
141-
Write(valueChars[1]);
142-
}
143-
}
144-
145128
// Writes a character array to the text stream. This default method calls
146129
// Write(char) for each of the characters in the character array.
147130
// If the character array is null, nothing is written.
@@ -360,26 +343,6 @@ public virtual void WriteLine(char value)
360343
WriteLine();
361344
}
362345

363-
/// <summary>
364-
/// Writes a rune followed by a line terminator to the text stream.
365-
/// </summary>
366-
/// <param name="value">The rune to write to the text stream.</param>
367-
public virtual void WriteLine(Rune value)
368-
{
369-
// Convert value to span
370-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
371-
372-
if (valueChars.Length > 1)
373-
{
374-
Write(valueChars[0]);
375-
WriteLine(valueChars[1]);
376-
}
377-
else
378-
{
379-
WriteLine(valueChars[0]);
380-
}
381-
}
382-
383346
// Writes an array of characters followed by a line terminator to the text
384347
// stream.
385348
//
@@ -579,28 +542,6 @@ public virtual Task WriteAsync(char value) =>
579542
t.Item1.Write(t.Item2);
580543
}, new TupleSlim<TextWriter, char>(this, value), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
581544

582-
/// <summary>
583-
/// Writes a rune to the text stream asynchronously.
584-
/// </summary>
585-
/// <param name="value">The rune to write to the text stream.</param>
586-
/// <returns>A task that represents the asynchronous write operation.</returns>
587-
public virtual Task WriteAsync(Rune value)
588-
{
589-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
590-
591-
if (valueChars.Length > 1)
592-
{
593-
return Task.Factory.StartNew(static state =>
594-
{
595-
var t = (TupleSlim<TextWriter, char, char>)state!;
596-
t.Item1.Write(t.Item2);
597-
t.Item1.Write(t.Item3);
598-
}, new TupleSlim<TextWriter, char, char>(this, valueChars[0], valueChars[1]), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
599-
}
600-
601-
return WriteAsync(valueChars[0]);
602-
}
603-
604545
public virtual Task WriteAsync(string? value) =>
605546
Task.Factory.StartNew(static state =>
606547
{
@@ -664,28 +605,6 @@ public virtual Task WriteLineAsync(char value) =>
664605
t.Item1.WriteLine(t.Item2);
665606
}, new TupleSlim<TextWriter, char>(this, value), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
666607

667-
/// <summary>
668-
/// Writes a rune followed by a line terminator to the text stream asynchronously.
669-
/// </summary>
670-
/// <param name="value">The rune to write to the text stream.</param>
671-
/// <returns>A task that represents the asynchronous write operation.</returns>
672-
public virtual Task WriteLineAsync(Rune value)
673-
{
674-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
675-
676-
if (valueChars.Length > 1)
677-
{
678-
return Task.Factory.StartNew(static state =>
679-
{
680-
var t = (TupleSlim<TextWriter, char, char>)state!;
681-
t.Item1.Write(t.Item2);
682-
t.Item1.WriteLine(t.Item3);
683-
}, new TupleSlim<TextWriter, char, char>(this, valueChars[0], valueChars[1]), CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
684-
}
685-
686-
return WriteLineAsync(valueChars[0]);
687-
}
688-
689608
public virtual Task WriteLineAsync(string? value) =>
690609
Task.Factory.StartNew(static state =>
691610
{

src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Numerics;
1010
using System.Runtime.CompilerServices;
1111
using System.Runtime.InteropServices;
12-
using System.Text;
1312
using System.Text.Unicode;
1413

1514
namespace System
@@ -590,44 +589,6 @@ public bool EndsWith(char value)
590589
return ((uint)lastPos < (uint)Length) && this[lastPos] == value;
591590
}
592591

593-
/// <summary>
594-
/// Determines whether the end of this string instance matches the specified character.
595-
/// </summary>
596-
/// <param name="value">The character to compare to the character at the end of this instance.</param>
597-
/// <param name="comparisonType">One of the enumeration values that specifies the rules to use in the comparison.</param>
598-
/// <returns><see langword="true"/> if <paramref name="value"/> matches the end of this instance; otherwise, <see langword="false"/>.</returns>
599-
public bool EndsWith(char value, StringComparison comparisonType)
600-
{
601-
// Convert value to span
602-
ReadOnlySpan<char> valueChars = [value];
603-
604-
return this.EndsWith(valueChars, comparisonType);
605-
}
606-
607-
/// <summary>
608-
/// Determines whether the end of this string instance matches the specified rune using an ordinal comparison.
609-
/// </summary>
610-
/// <param name="value">The character to compare to the character at the end of this instance.</param>
611-
/// <returns><see langword="true"/> if <paramref name="value"/> matches the end of this instance; otherwise, <see langword="false"/>.</returns>
612-
public bool EndsWith(Rune value)
613-
{
614-
return EndsWith(value, StringComparison.Ordinal);
615-
}
616-
617-
/// <summary>
618-
/// Determines whether the end of this string instance matches the specified rune when compared using the specified comparison option.
619-
/// </summary>
620-
/// <param name="value">The character to compare to the character at the end of this instance.</param>
621-
/// <param name="comparisonType">One of the enumeration values that specifies the rules to use in the comparison.</param>
622-
/// <returns><see langword="true"/> if <paramref name="value"/> matches the end of this instance; otherwise, <see langword="false"/>.</returns>
623-
public bool EndsWith(Rune value, StringComparison comparisonType)
624-
{
625-
// Convert value to span
626-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
627-
628-
return this.EndsWith(valueChars, comparisonType);
629-
}
630-
631592
// Determines whether two strings match.
632593
public override bool Equals([NotNullWhen(true)] object? obj)
633594
{
@@ -1201,44 +1162,6 @@ public bool StartsWith(char value)
12011162
return Length != 0 && _firstChar == value;
12021163
}
12031164

1204-
/// <summary>
1205-
/// Determines whether the beginning of this string instance matches the specified character when compared using the specified comparison option.
1206-
/// </summary>
1207-
/// <param name="value">The character to compare.</param>
1208-
/// <param name="comparisonType">One of the enumeration values that determines how this string and <paramref name="value"/> are compared.</param>
1209-
/// <returns><see langword="true"/> if value matches the beginning of this string; otherwise, <see langword="false"/>.</returns>
1210-
public bool StartsWith(char value, StringComparison comparisonType)
1211-
{
1212-
// Convert value to span
1213-
ReadOnlySpan<char> valueChars = [value];
1214-
1215-
return this.StartsWith(valueChars, comparisonType);
1216-
}
1217-
1218-
/// <summary>
1219-
/// Determines whether the beginning of this string instance matches the specified rune using an ordinal comparison.
1220-
/// </summary>
1221-
/// <param name="value">The rune to compare.</param>
1222-
/// <returns><see langword="true"/> if value matches the beginning of this string; otherwise, <see langword="false"/>.</returns>
1223-
public bool StartsWith(Rune value)
1224-
{
1225-
return StartsWith(value, StringComparison.Ordinal);
1226-
}
1227-
1228-
/// <summary>
1229-
/// Determines whether the beginning of this string instance matches the specified rune when compared using the specified comparison option.
1230-
/// </summary>
1231-
/// <param name="value">The rune to compare.</param>
1232-
/// <param name="comparisonType">One of the enumeration values that determines how this string and <paramref name="value"/> are compared.</param>
1233-
/// <returns><see langword="true"/> if value matches the beginning of this string; otherwise, <see langword="false"/>.</returns>
1234-
public bool StartsWith(Rune value, StringComparison comparisonType)
1235-
{
1236-
// Convert value to span
1237-
ReadOnlySpan<char> valueChars = value.AsSpan(stackalloc char[Rune.MaxUtf16CharsPerRune]);
1238-
1239-
return this.StartsWith(valueChars, comparisonType);
1240-
}
1241-
12421165
internal static void CheckStringComparison(StringComparison comparisonType)
12431166
{
12441167
// Single comparison to check if comparisonType is within [CurrentCulture .. OrdinalIgnoreCase]

0 commit comments

Comments
 (0)