Skip to content

string.Contains returns wrong result on net-ios with .net 9 #110609

Open
@markuspalme

Description

Description

string.Contains returns unexpected results when called on an empty string on iOS. This is the code in question:

"".Contains("ö", StringComparison.CurrentCultureIgnoreCase);

Results:

.net 8:

Image

.net 9:

Image

Project to reproduce the issue:
https://github.com/markuspalme/dotnetruntime-contains

Reproduction Steps

To reproduce the issue, call string.Containson an empty string and run the code on net9-ios:

"".Contains("ö", StringComparison.CurrentCultureIgnoreCase);

Expected behavior

The result should be false, an empty string does certainly not contain a character.

Actual behavior

On .net 9 the call returns true.

Regression?

This is a regression, the same code returns false on .net 8.

Known Workarounds

No response

Configuration

.net SDK 9.0.100 running on iOS 18.1 ARM64.

Other information

No response

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions