-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add missing overloads to flow rune proposal #120314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add missing overloads to flow rune proposal #120314
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds new String and Char overloads to support searching for char and Rune with StringComparison and startIndex/count parameters, plus a Char.Equals overload with StringComparison. Updates reference assembly, core implementations, span helpers, and expands tests accordingly.
- Adds IndexOf/LastIndexOf overloads for char and Rune with (startIndex, comparisonType) and (startIndex, count, comparisonType).
- Exposes Char.Equals(char, StringComparison) publicly and adds corresponding tests.
- Implements ordinal ignore-case search helpers and supporting SpanHelpers last-index routines.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
System.Runtime.Tests/System/StringTests.cs | Updated and expanded tests for new IndexOf/LastIndexOf overloads (char and Rune) with startIndex/count + comparison. |
System.Runtime.Tests/System/CharTests.cs | Added tests for new Char.Equals with StringComparison and adjusted existing equality tests. |
System.Runtime/ref/System.Runtime.cs | Added new public API surface for String and Char overloads. |
System.Private.CoreLib/src/System/String.Searching.cs | Implemented new overloads, publicized Rune variants, and added ordinal ignore-case logic for ranged search. |
System.Private.CoreLib/src/System/SpanHelpers.T.cs | Added LastIndexOfChar / LastIndexOfAnyChar helpers for performance support. |
System.Private.CoreLib/src/System/Char.cs | Made Char.Equals(char, StringComparison) public with XML docs. |
src/libraries/System.Private.CoreLib/src/System/String.Searching.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/String.Searching.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/CharTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/CharTests.cs
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Show resolved
Hide resolved
@tarekgh I will continue working on this tomorrow hopefully. I have sort of lost track of your reviews here, so summarising/updating them would be nice :) |
Thanks for your effort. no rush too. If you like, ignore all my comments (close them) and I'll take a full review again after you have the latest update, so you don't have to worry about missing anything. |
I have encountered a consistency problem with empty strings. @tarekgh If you choose an out-of-bounds index with Console.WriteLine("".IndexOf('b', 0)); // -1
Console.WriteLine("".IndexOf("b", 0)); // -1
Console.WriteLine("a".IndexOf('b', 1)); // -1
Console.WriteLine("a".IndexOf("b", 1)); // -1
Console.WriteLine("a".IndexOf('b', 2)); // exception (startIndex > Length)
Console.WriteLine("a".IndexOf("b", 2)); // exception (startIndex > Length) But if you choose an out-of-bounds index with Console.WriteLine("".LastIndexOf('b', 0)); // -1
Console.WriteLine("".LastIndexOf("b", 0)); // -1
Console.WriteLine("a".LastIndexOf('b', 1)); // exception (startIndex >= Length)
Console.WriteLine("a".LastIndexOf("b", 1)); // -1
Console.WriteLine("a".LastIndexOf('b', 2)); // exception (startIndex >= Length)
Console.WriteLine("a".LastIndexOf("b", 2)); // exception (startIndex > Length) This leaves us with a few choices:
|
We need to figure out if this is going to cause any issue with F# like the previous added APIs did. |
My understanding it will break F#. For example: We are adding public int LastIndexOf(char value, System.StringComparison comparisonType) which will conflict with the existing one public int LastIndexOf(char value, int startIndex) |
Yeah, sorry I deleted that comment after understanding it may break the code. But if we don't accept these changes, this limitation would make it almost impossible to add new overloads into .NET due to F#'s type inference. |
Let's hold on this PR till we resolve the F# issue in general. |
@Joy-less let us not stop continuing updating this PR so we can be ready when we decide to merge. Thanks! |
Understood, please could you help with this issue if it is clear? #120314 (comment) |
Let’s proceed with the following behavior:
I chose this behavior for the following reasons:
|
@tarekgh I have added the |
Closes #120015 proposal.
Adds the following APIs with refs and tests:
NOTE:This pull request ignores the two amendments listed in #120015 (comment). It should not be merged until those amendments are approved/rejected.
@tarekgh