Skip to content

Commit

Permalink
Add net8.0 target.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCleary committed Dec 2, 2023
1 parent 57f15f6 commit 51ed176
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
22 changes: 16 additions & 6 deletions src/Nito.Collections.Deque/CollectionHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ internal static class CollectionHelpers
{
public static IReadOnlyCollection<T> ReifyCollection<T>(IEnumerable<T> source)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
#if NET461 || NETSTANDARD1_0 || NETSTANDARD2_0
_ = source ?? throw new ArgumentNullException(nameof(source));
#else
ArgumentNullException.ThrowIfNull(source);
#endif

var result = source as IReadOnlyCollection<T>;
if (result != null)
Expand All @@ -30,8 +33,12 @@ private sealed class NongenericCollectionWrapper<T> : IReadOnlyCollection<T>

public NongenericCollectionWrapper(ICollection collection)
{
if (collection == null)
throw new ArgumentNullException(nameof(collection));
#if NET461 || NETSTANDARD1_0 || NETSTANDARD2_0
_ = collection ?? throw new ArgumentNullException(nameof(collection));
#else
ArgumentNullException.ThrowIfNull(collection);
#endif

_collection = collection;
}

Expand Down Expand Up @@ -61,8 +68,11 @@ private sealed class CollectionWrapper<T> : IReadOnlyCollection<T>

public CollectionWrapper(ICollection<T> collection)
{
if (collection == null)
throw new ArgumentNullException(nameof(collection));
#if NET461 || NETSTANDARD1_0 || NETSTANDARD2_0
_ = collection ?? throw new ArgumentNullException(nameof(collection));
#else
ArgumentNullException.ThrowIfNull(collection);
#endif
_collection = collection;
}

Expand Down
25 changes: 17 additions & 8 deletions src/Nito.Collections.Deque/Deque.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ public Deque(int capacity)
/// <param name="collection">The collection. May not be <c>null</c>.</param>
public Deque(IEnumerable<T> collection)
{
if (collection == null)
throw new ArgumentNullException(nameof(collection));
#if NET461 || NETSTANDARD1_0 || NETSTANDARD2_0
_ = collection ?? throw new ArgumentNullException(nameof(collection));
#else
ArgumentNullException.ThrowIfNull(collection);
#endif

var source = CollectionHelpers.ReifyCollection(collection);
var count = source.Count;
Expand Down Expand Up @@ -142,10 +145,13 @@ bool ICollection<T>.Contains(T item)
/// <inheritdoc/>
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
#if NET461 || NETSTANDARD1_0 || NETSTANDARD2_0
_ = array ?? throw new ArgumentNullException(nameof(array));
#else
ArgumentNullException.ThrowIfNull(array);
#endif

int count = Count;
int count = Count;
CheckRangeArguments(array.Length, arrayIndex, count);
CopyToArray(array, arrayIndex);
}
Expand All @@ -157,10 +163,13 @@ void ICollection<T>.CopyTo(T[] array, int arrayIndex)
/// <param name="arrayIndex">The optional index in the destination array at which to begin writing.</param>
private void CopyToArray(Array array, int arrayIndex = 0)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
#if NET461 || NETSTANDARD1_0 || NETSTANDARD2_0
_ = array ?? throw new ArgumentNullException(nameof(array));
#else
ArgumentNullException.ThrowIfNull(array);
#endif

if (IsSplit)
if (IsSplit)
{
// The existing buffer is split, so we have to copy it in parts
int length = Capacity - _offset;
Expand Down
2 changes: 1 addition & 1 deletion src/Nito.Collections.Deque/Nito.Collections.Deque.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A double-ended queue.</Description>
<TargetFrameworks>netstandard1.0;netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard1.0;netstandard2.0;net461;net8.0</TargetFrameworks>
<PackageTags>collection;deque;dequeue</PackageTags>
</PropertyGroup>

Expand Down

0 comments on commit 51ed176

Please sign in to comment.