From bdef9b144238bec4f8e7475f5cbf925197f58de6 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 14 Nov 2024 17:35:19 +0000 Subject: [PATCH] refactor!: remove DateOnly.Deconstruct --- CHANGELOG.md | 4 +++- X10D.Tests/src/Time/DateOnlyTests.cs | 24 ------------------------ X10D/src/Time/DateOnlyExtensions.cs | 14 -------------- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cf7ea801..321716223 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,8 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed +- X10D: Removed `DateOnly.Deconstruct` due to conflict with +[`System.DateOnly.Deconstruct`](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.deconstruct?view=net-8.0). - X10D: Removed `Span.Split` for .NET 9.0 target due to conflicts with -[`System.MemoryExtensions.Split`](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-8.0). +[`System.MemoryExtensions.Split`](https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.split?view=net-9.0). ## [4.0.0] - 2024-06-12 diff --git a/X10D.Tests/src/Time/DateOnlyTests.cs b/X10D.Tests/src/Time/DateOnlyTests.cs index 25dc25dea..868c8e409 100644 --- a/X10D.Tests/src/Time/DateOnlyTests.cs +++ b/X10D.Tests/src/Time/DateOnlyTests.cs @@ -39,30 +39,6 @@ public void Age_ShouldBe18_Given31December1991Birthday_And31December2017Date() Assert.That(age, Is.EqualTo(18)); } - [Test] - public void Deconstruct_ShouldDeconstruct_GivenDateOnly() - { - var date = new DateOnly(2017, 12, 31); - - date.Deconstruct(out int year, out int month, out int day); - - Assert.That(year, Is.EqualTo(2017)); - Assert.That(month, Is.EqualTo(12)); - Assert.That(day, Is.EqualTo(31)); - } - - [Test] - public void Deconstruct_ShouldDeconstructToTuple_GivenDateOnly() - { - var date = new DateOnly(2017, 12, 31); - - (int year, int month, int day) = date; - - Assert.That(year, Is.EqualTo(2017)); - Assert.That(month, Is.EqualTo(12)); - Assert.That(day, Is.EqualTo(31)); - } - [Test] public void First_ShouldBeSaturday_Given1Jan2000() { diff --git a/X10D/src/Time/DateOnlyExtensions.cs b/X10D/src/Time/DateOnlyExtensions.cs index fd59001ba..39dc5d3f4 100644 --- a/X10D/src/Time/DateOnlyExtensions.cs +++ b/X10D/src/Time/DateOnlyExtensions.cs @@ -39,20 +39,6 @@ public static int Age(this DateOnly value, DateOnly referenceDate) return value.ToDateTime(default).Age(referenceDate.ToDateTime(default)); } - /// - /// Deconstructs the current into its year, month, and day. - /// - /// The date to deconstruct. - /// When this method returns, contains the year. - /// When this method returns, contains the month. - /// When this method returns, contains the day. - public static void Deconstruct(this DateOnly value, out int year, out int month, out int day) - { - year = value.Year; - month = value.Month; - day = value.Day; - } - /// /// Gets a date representing the first occurence of a specified day of the week in the current month. ///