You've already forked linux-packaging-mono
Imported Upstream version 6.0.0.241
Former-commit-id: 6bb91ae3d8008b2e06beaf4212ad32102b270e2a
This commit is contained in:
parent
2bc8cfd5d0
commit
1efc83b696
@ -252,20 +252,18 @@ namespace System.Globalization
|
||||
if (source.IsEmpty)
|
||||
return;
|
||||
|
||||
var ti = CultureInfo.CurrentCulture.TextInfo;
|
||||
|
||||
fixed (char* pSource = &MemoryMarshal.GetReference (source))
|
||||
fixed (char* pResult = &MemoryMarshal.GetReference (destination)) {
|
||||
int length = 0;
|
||||
char* a = pSource, b = pResult;
|
||||
if (toUpper) {
|
||||
while (length < source.Length) {
|
||||
*b++ = ti.ToUpper (*a++);
|
||||
*b++ = this.ToUpper (*a++);
|
||||
length++;
|
||||
}
|
||||
} else {
|
||||
while (length < source.Length) {
|
||||
*b++ = ti.ToLower (*a++);
|
||||
*b++ = this.ToLower (*a++);
|
||||
length++;
|
||||
}
|
||||
}
|
||||
|
@ -776,5 +776,23 @@ namespace MonoTests.System.Globalization
|
||||
|
||||
Assert.IsTrue (f ().Wait (5 * 1000), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SpanToUpperInvariantDoesntUseCurrentCulture ()
|
||||
{
|
||||
string testStr = "test";
|
||||
var dst = new Span<char> (new char [testStr.Length]);
|
||||
CultureInfo savedCulture = CultureInfo.CurrentCulture;
|
||||
CultureInfo.CurrentCulture = new InterceptingLocale ();
|
||||
testStr.AsSpan ().ToUpperInvariant (dst); // should not throw InvalidOperationException ("Shouldn't be called.")
|
||||
CultureInfo.CurrentCulture = savedCulture;
|
||||
Assert.AreEqual ("TEST", dst.ToString ());
|
||||
}
|
||||
|
||||
private class InterceptingLocale : CultureInfo
|
||||
{
|
||||
public InterceptingLocale () : base (string.Empty) { }
|
||||
public override TextInfo TextInfo => throw new InvalidOperationException ("Shouldn't be called.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user