Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libraries/Common/tests/Tests/System/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ void Validate(string result)
Validate(string.Concat((ReadOnlySpan<string?>)values));
Validate(string.Concat((IEnumerable<string>)values));
Validate(string.Concat<string>((IEnumerable<string>)values)); // Call the generic IEnumerable<T>-based overload
Validate(string.Concat(values.Select(s => s)));
Validate(string.Concat(new List<string?>(values)));
Comment thread
prozolic marked this conversation as resolved.
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsMultithreadingSupported))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ public static unsafe string Concat(IEnumerable<string?> values)
{
ArgumentNullException.ThrowIfNull(values);

if (values.GetType() == typeof(List<string?>))
Comment thread
prozolic marked this conversation as resolved.
Outdated
{
return Concat(CollectionsMarshal.AsSpan((List<string?>)values));
}

if (values is string?[] valuesArray)
{
return Concat((ReadOnlySpan<string?>)valuesArray);
}
Comment thread
prozolic marked this conversation as resolved.
Outdated
Comment thread
prozolic marked this conversation as resolved.

using (IEnumerator<string?> en = values.GetEnumerator())
{
if (!en.MoveNext())
Expand Down
Loading