From ea57ac86bdc1ee643af6de2cdc71e774a643a426 Mon Sep 17 00:00:00 2001 From: Paul Welter Date: Thu, 14 Nov 2024 08:41:35 -0600 Subject: [PATCH] update to .net 9 --- .../Equatable.Comparers.csproj | 2 +- .../Equatable.Generator.csproj | 2 +- src/Equatable.SourceGenerator/IsExternalInit.cs | 13 +------------ .../Models/EquatableArray.cs | 17 +++++++++++++++-- .../Equatable.Entities.csproj | 5 ++++- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Equatable.Comparers/Equatable.Comparers.csproj b/src/Equatable.Comparers/Equatable.Comparers.csproj index 210f0ca..50eec23 100644 --- a/src/Equatable.Comparers/Equatable.Comparers.csproj +++ b/src/Equatable.Comparers/Equatable.Comparers.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net6.0;net8.0 + netstandard2.0;net8.0;net9.0 diff --git a/src/Equatable.Generator/Equatable.Generator.csproj b/src/Equatable.Generator/Equatable.Generator.csproj index 9124fde..09c8599 100644 --- a/src/Equatable.Generator/Equatable.Generator.csproj +++ b/src/Equatable.Generator/Equatable.Generator.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net6.0;net8.0 + netstandard2.0;net8.0;net9.0 Equatable diff --git a/src/Equatable.SourceGenerator/IsExternalInit.cs b/src/Equatable.SourceGenerator/IsExternalInit.cs index 40f1f7b..75cd67b 100644 --- a/src/Equatable.SourceGenerator/IsExternalInit.cs +++ b/src/Equatable.SourceGenerator/IsExternalInit.cs @@ -1,17 +1,6 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - using System.ComponentModel; -// ReSharper disable once CheckNamespace namespace System.Runtime.CompilerServices; -/// -/// Reserved to be used by the compiler for tracking metadata. -/// This class should not be used by developers in source code. -/// [EditorBrowsable(EditorBrowsableState.Never)] -internal static class IsExternalInit -{ -} +internal static class IsExternalInit; diff --git a/src/Equatable.SourceGenerator/Models/EquatableArray.cs b/src/Equatable.SourceGenerator/Models/EquatableArray.cs index b629e99..a74a395 100644 --- a/src/Equatable.SourceGenerator/Models/EquatableArray.cs +++ b/src/Equatable.SourceGenerator/Models/EquatableArray.cs @@ -4,13 +4,24 @@ namespace Equatable.SourceGenerator.Models; [ExcludeFromCodeCoverage] -public readonly struct EquatableArray(T[] array) : IEquatable>, IEnumerable +public readonly struct EquatableArray : IEquatable>, IEnumerable where T : IEquatable { - public T[] Array { get; } = array ?? []; + public static readonly EquatableArray Empty = new(); + + + public EquatableArray() : this([]) { } + + public EquatableArray(T[] array) => Array = array ?? []; + + public EquatableArray(IEnumerable items) => Array = items.ToArray() ?? []; + + + public T[] Array { get; } public int Count => Array.Length; + public ReadOnlySpan AsSpan() => Array.AsSpan(); public T[] AsArray() => Array; @@ -44,4 +55,6 @@ public override int GetHashCode() public static implicit operator EquatableArray(T[] array) => new(array); + + public static implicit operator EquatableArray(List items) => new(items); } diff --git a/test/Equatable.Entities/Equatable.Entities.csproj b/test/Equatable.Entities/Equatable.Entities.csproj index 0c64064..b39f78a 100644 --- a/test/Equatable.Entities/Equatable.Entities.csproj +++ b/test/Equatable.Entities/Equatable.Entities.csproj @@ -1,10 +1,13 @@ - netstandard2.0;net6.0;net8.0 + netstandard2.0;net8.0;net9.0 false enable latest + + + true