Skip to content

[iOS][globalization] Fix IndexOf on empty strings on iOS to return -1 - #111898

Merged
matouskozak merged 2 commits into
dotnet:mainfrom
matouskozak:fix-indexOf-empty-strings
Jan 30, 2025
Merged

matouskozak merged 2 commits into
dotnet:mainfrom
matouskozak:fix-indexOf-empty-strings

Conversation

@matouskozak

@matouskozak matouskozak commented Jan 28, 2025 •

Copy link
Copy Markdown
Member

Fix incorrect return condition and add test case for IndexOf("", <something>) and "".Contains(<something>).

Clean-up of some styling issues and adding comments.


This PR should fix:

and needs to be backported to .NET 9

@dotnet-policy-service

ghost commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-globalization
See info in area-owners.md if you want to be subscribed.

@matouskozak

ghost commented Jan 28, 2025

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike,runtime-ioslikesimulator,runtime-maccatalyst

@azure-pipelines

ghost commented Jan 28, 2025

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@matouskozak

ghost commented Jan 28, 2025

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

ghost commented Jan 28, 2025

Copy link
Copy Markdown
Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@matouskozak
matouskozak marked this pull request as ready for review January 28, 2025 17:01
}

/**
* Removes zero-width and other weightless characters such as U+200B (Zero Width Space),

ghost Jan 28, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Removes zero-width and other weightless characters such as U+200B (Zero Width Space),

just in case if this need to change later, it will be good to look at the full list of ignorable characters https://www.unicode.org/charts/collation/chart_Ignored.html

@matouskozak

ghost commented Jan 29, 2025

Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines

ghost commented Jan 29, 2025

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable - but I don't understand the code that well.

@matouskozak
matouskozak merged commit 4e01649 into dotnet:main Jan 30, 2025
@matouskozak

ghost commented Jan 30, 2025

Copy link
Copy Markdown
Member Author

/backport to release/9.0-staging

@github-actions

ghost commented Jan 30, 2025

Copy link
Copy Markdown
Contributor

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/13057341292

@github-actions

ghost commented Jan 30, 2025

Copy link
Copy Markdown
Contributor

@matouskozak backporting to "release/9.0-staging" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix IndexOf on empty strings on iOS to return -1
.git/rebase-apply/patch:80: trailing whitespace.
 * Removes zero-width and other weightless characters such as U+200B (Zero Width Space), 
.git/rebase-apply/patch:81: trailing whitespace.
 * U+200C (Zero Width Non-Joiner), U+200D (Zero Width Joiner), U+FEFF (Zero Width No-Break Space), 
warning: 2 lines add whitespace errors.
Using index info to reconstruct a base tree...
M	src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.IndexOf.cs
M	src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs
Auto-merging src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.IndexOf.cs
CONFLICT (content): Merge conflict in src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.IndexOf.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Fix IndexOf on empty strings on iOS to return -1
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@JeroenBer

ghost commented Feb 15, 2025

Copy link
Copy Markdown

@matouskozak
Will this fix be in 9.0.3 ?

@tarekgh

ghost commented Feb 15, 2025 •

Copy link
Copy Markdown
Member

This doesn’t seem to have made the cutoff for .NET servicing 9.0.3, so it will most likely be included in the 9.0.4 release in April.

@JeroenBer

ghost commented Feb 15, 2025

Copy link
Copy Markdown

Where can I track that ? I don't see any 9.0.3 cutoff ?
9.0.2 was just released.

@matouskozak

ghost commented Feb 17, 2025

Copy link
Copy Markdown
Member Author

Where can I track that ? I don't see any 9.0.3 cutoff ? 9.0.2 was just released.

The cutoff for servicing X usually happens around the time the servicing X-1 is released.

@github-actions github-actions Bot locked and limited conversation to collaborators Mar 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants