Skip to content

IndexOf with matchLength is not supported on iOS #111506

Closed
@rmarinho

Description

Description

The .net MAUI team is moving to .net10 and we got a failure on some tests that are running on iOS that were working previous on .net9.

This seems like a bug or a breaking change.

Reproduction Steps

Try run the following program on iOS or Catalyst

using System;
using System.Runtime.InteropServices;

using Foundation;

namespace MySimpleApp {
	public class Program {
		static int Main (string [] args)
		{
			GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly

			Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD"));

			var data = new [] {
				( Url: "https://test.com/file", Expected: "{hash}" ),
				( Url: "https://test.com/file#test", Expected: "{hash}" ),
				( Url: "https://test.com/file#test=123", Expected: "{hash}" ),
				( Url: "https://test.com/file?test", Expected: "{hash}" ),
				( Url: "https://test.com/file?test=123", Expected: "{hash}" ),
				( Url: "https://test.com/file.png",  Expected: "{hash}.png" ),
				( Url: "https://test.com/file.jpg",  Expected: "{hash}.jpg" ),
				( Url: "https://test.com/file.gif",  Expected: "{hash}.gif" ),
				( Url: "https://test.com/file.jpg?ids",  Expected: "{hash}.jpg" ),
				( Url: "https://test.com/file.jpg?id=123",  Expected: "{hash}.jpg" ),
				( Url: "https://test.com/file.gif#id=123",  Expected: "{hash}.gif" ),
				( Url: "https://test.com/file.gif#ids",  Expected: "{hash}.gif" ),
			};

			foreach (var obj in data) {
				CachedFilenameIsCorrectAndValid (obj.Url, obj.Expected);
			}

			return args.Length;
		}

		public static void CachedFilenameIsCorrectAndValid(string uri, string expected)
		{
			// using var algorithm = new Crc64HashAlgorithm();
			var hashed = uri + "hash"; // algorithm.ComputeHashString(uri);
			expected = expected.Replace("{hash}", hashed, StringComparison.OrdinalIgnoreCase);

			// var service = new UriImageSourceService();

			// var filename = service.GetCachedFileName(new UriImageSourceStub { Uri = new Uri(uri) });

			// Assert.Equal(expected, filename);
		}
	}
}

Expected behavior

The program above should work without crashing.

Actual behavior

  Exception messages: System.PlatformNotSupportedException : Match length calculation is not supported when HybridGlobalization=true. Disable it to load larger ICU bundle, then use this function.   Exception stack traces:    at System.Globalization.CompareInfo.IndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, Int32* matchLengthPtr, CompareOptions options, Boolean fromBeginning)

Regression?

We think this is a regression as this works fine on net9.

Known Workarounds

No response

Configuration

  • .net10
  • iOS and MacCatalyst
  • arm64

Other information

We have reached out to @matouskozak and @steveisok about this issue.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions