Hi, I would like to buff spread with C# 12 collection initializer:
Spread<object> mySpread = ["What", "So", "Ever"];
The changes seems quite lightweight:
using System.Runtime.CompilerServices;
// ...
[CollectionBuilder(typeof(Spread), nameof(Spread.Create))]
[Serializable]
public sealed class Spread<T> : IReadOnlyList<T>, IHasMemory<T>, ISpread, IList<T> /* LINQ looks for IList and not IReadOnlyList */
{
// ...
}
public static class Spread
{
// Collection expression support
public static Spread<T> Create<T>(ReadOnlySpan<T> items)
{
if (items.Length > 0)
return new Spread<T>(ImmutableArray.Create(items));
return Spread<T>.Empty;
}
// ...
}
Are there any cons against submitting pull request?
The only side effect this is .net8.0+