Skip to content

Commit 0c500f4

Browse files
authored
Merge pull request #2195 from Unity-Technologies/6000.0-backport-117367
[6000.0] Fix the System.String.Replace throwing NotImplementedException (mono#20960)
2 parents c1c14b4 + 94ebd83 commit 0c500f4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mcs/class/corlib/Test/System/StringTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,6 +3221,10 @@ public void Replace()
32213221

32223222
// Test replacing null characters (bug #67395)
32233223
Assert.AreEqual ("is this ok ?", "is \0 ok ?".Replace ("\0", "this"), "should not strip content after nullchar");
3224+
3225+
// System.String.Replace fails with NotImplementedException https://github.com/mono/mono/issues/20948
3226+
Assert.AreEqual ("Original", s1.Replace("o", "O", StringComparison.CurrentCulture), "Replace(string, string, StringComparison)");
3227+
Assert.AreEqual ("Original", s1.Replace("o", "O", false, CultureInfo.CurrentCulture), "Replace(string, string, bool, CultureInfo)");
32243228
}
32253229

32263230
[Test]

mcs/class/corlib/corefx/CompareInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int LastIndexOfCore (string source, string target, int startIndex, int count, Co
8686
unsafe int IndexOfCore (string source, string target, int startIndex, int count, CompareOptions options, int* matchLengthPtr)
8787
{
8888
if (matchLengthPtr != null)
89-
throw new NotImplementedException ();
89+
*matchLengthPtr = target.Length;
9090

9191
return internal_index_switch (source, startIndex, count, target, options, true);
9292
}

0 commit comments

Comments
 (0)