-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add ROSpan ToLower and ToUpper string-like APIs with CultureInfo #27193
Conversation
| return -1; | ||
|
|
||
| string sourceString = source.ToString(); | ||
| string resultString = sourceString.ToLower(culture); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unfortunate we need to allocate here (potentially twice), but I don't have a better answer (unless we want to make the API netcoreapp-specific).
| [Fact] | ||
| public static void Test_ToLower_Culture() | ||
| { | ||
| foreach (var testdata in ToLower_Culture_TestData()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use a Theory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably. I borrowed this from the existing string tests and tweaked it a bit.
| /// <param name="culture">An object that supplies culture-specific casing rules.</param> | ||
| /// <exception cref="System.ArgumentNullException"> | ||
| /// Thrown when <paramref name="culture"/> is null. | ||
| /// </exception> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add remarks saying whether the source and destination can be overlapping (or the same span)
|
@dotnet-bot test this please |
|
ToLower(CultureInfo) was added in netstandard2.0. What can we do for netstandard1.1? |
|
@ahsonkhan you can use CultureInfo.TextInfo.ToLower |
|
|
|
@dotnet-bot test Windows x64 Debug Build |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test Linux x64 Release Build |
|
Linux x64 Release Build |
…net/corefx#27193) * Add ROSpan ToLower and ToUpper string-like APIs with CultureInfo * Add comment about overlapping spans + test. * Respond to recent change AsReadOnlySpan -> AsSpan and use Theory * Add System.Globalization for netstandard1.1 * Use TextInfo.ToLower/ToUpper for netstandard1.1 * Fix XML comment Commit migrated from dotnet/corefx@865f086
Part of https://github.com/dotnet/corefx/issues/21395#issuecomment-359906138
Depends on: dotnet/coreclr#16379 and dotnet/coreclr#16496
cc @jkotas, @stephentoub, @KrzysztofCwalina, @tarekgh, @JeremyKuhne, @joshfree