diff --git a/Directory.Build.props b/Directory.Build.props index 023b02b..4d7793f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ true - 11.0 + 12.0 enable true diff --git a/src/PolySharp.SourceGenerators/Helpers/EquatableArray{T}.cs b/src/PolySharp.SourceGenerators/Helpers/EquatableArray{T}.cs index 74b57dc..95eb9af 100644 --- a/src/PolySharp.SourceGenerators/Helpers/EquatableArray{T}.cs +++ b/src/PolySharp.SourceGenerators/Helpers/EquatableArray{T}.cs @@ -33,22 +33,14 @@ public static EquatableArray AsEquatableArray(this ImmutableArray array /// An imutable, equatable array. This is equivalent to but with value equality support. /// /// The type of values in the array. -internal readonly struct EquatableArray : IEquatable>, IEnumerable +/// The input to wrap. +internal readonly struct EquatableArray(ImmutableArray array) : IEquatable>, IEnumerable where T : IEquatable { /// /// The underlying array. /// - private readonly T[]? array; - - /// - /// Creates a new instance. - /// - /// The input to wrap. - public EquatableArray(ImmutableArray array) - { - this.array = Unsafe.As, T[]?>(ref array); - } + private readonly T[]? array = Unsafe.As, T[]?>(ref array); /// /// Gets a reference to an item at a specified position within the array. @@ -144,7 +136,7 @@ public static EquatableArray FromImmutableArray(ImmutableArray array) /// A wrapping the current items. public ReadOnlySpan AsSpan() { - return AsImmutableArray().AsSpan(); + return new(this.array); } /// @@ -153,7 +145,7 @@ public ReadOnlySpan AsSpan() /// The newly instantiated array. public T[] ToArray() { - return AsImmutableArray().ToArray(); + return [.. AsSpan()]; } ///