From 7424fa24c8655e8a7e9562a4a5c3d5a7379b797b Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 30 Nov 2023 18:32:48 +0100 Subject: [PATCH 1/4] Prepare for 4.2 --- MoreLinq/MoreLinq.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MoreLinq/MoreLinq.csproj b/MoreLinq/MoreLinq.csproj index 38d48eee5..d21855c5e 100644 --- a/MoreLinq/MoreLinq.csproj +++ b/MoreLinq/MoreLinq.csproj @@ -119,7 +119,7 @@ $([System.Text.RegularExpressions.Regex]::Replace($(Copyright), `\s+`, ` `).Trim()) MoreLINQ en-US - 4.1.0 + 4.2.0 MoreLINQ Developers. netstandard2.0;netstandard2.1;net6.0;net8.0 portable @@ -136,7 +136,7 @@ ..\dist README.md true - 4.0.0 + 4.1.0 true true true From ab184db01e6b38b34ba3cff6a2b8683f8326bcbb Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 30 Nov 2023 18:37:40 +0100 Subject: [PATCH 2/4] Remove extra blank lines in "ToDataTable" tests --- MoreLinq.Test/ToDataTableTest.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/MoreLinq.Test/ToDataTableTest.cs b/MoreLinq.Test/ToDataTableTest.cs index 9b4249d62..e13bbdada 100644 --- a/MoreLinq.Test/ToDataTableTest.cs +++ b/MoreLinq.Test/ToDataTableTest.cs @@ -41,10 +41,8 @@ sealed class TestObject(int key) public override string ToString() => nameof(TestObject); } - readonly IReadOnlyCollection testObjects; - public ToDataTableTest() => this.testObjects = Enumerable.Range(0, 3) .Select(i => new TestObject(i)) @@ -174,7 +172,6 @@ public void ToDataTableWithSchema() readonly struct Point { - #pragma warning disable CA1805 // Do not initialize unnecessarily (avoids CS0649) public static Point Empty = new(); #pragma warning restore CA1805 // Do not initialize unnecessarily From c4cd0519b538ec0a221598ce0266e243c86aace0 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 30 Nov 2023 18:38:50 +0100 Subject: [PATCH 3/4] Use primary constructor for test "Point" --- MoreLinq.Test/ToDataTableTest.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MoreLinq.Test/ToDataTableTest.cs b/MoreLinq.Test/ToDataTableTest.cs index e13bbdada..d6cac4cda 100644 --- a/MoreLinq.Test/ToDataTableTest.cs +++ b/MoreLinq.Test/ToDataTableTest.cs @@ -170,15 +170,14 @@ public void ToDataTableWithSchema() Assert.That(rows.Select(r => r["Value"]).ToArray(), Is.EqualTo(vars.Select(e => e.Value).ToArray())); } - readonly struct Point + readonly struct Point(int x, int y) { #pragma warning disable CA1805 // Do not initialize unnecessarily (avoids CS0649) public static Point Empty = new(); #pragma warning restore CA1805 // Do not initialize unnecessarily public bool IsEmpty => X == 0 && Y == 0; - public int X { get; } - public int Y { get; } - public Point(int x, int y) : this() { X = x; Y = y; } + public int X { get; } = x; + public int Y { get; } = y; } [Test] From 47a14cb22091f464b582e083a6842bc4ef6589f4 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Thu, 30 Nov 2023 18:40:22 +0100 Subject: [PATCH 4/4] Use object pattern to get value in tests --- MoreLinq.Test/SequenceTest.cs | 5 +++-- MoreLinq.Test/TraceTest.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MoreLinq.Test/SequenceTest.cs b/MoreLinq.Test/SequenceTest.cs index ad01a274d..4c75ff43f 100644 --- a/MoreLinq.Test/SequenceTest.cs +++ b/MoreLinq.Test/SequenceTest.cs @@ -110,8 +110,9 @@ public void SequenceWithDescendingRangeDescendigStep(int start, int stop, int st [TestCase(int.MinValue, int.MinValue, null)] public void SequenceWithStartEqualsStop(int start, int stop, int? step) { - var result = step.HasValue ? MoreEnumerable.Sequence(start, stop, step.Value) - : MoreEnumerable.Sequence(start, stop); + var result = step is { } someStep + ? MoreEnumerable.Sequence(start, stop, someStep) + : MoreEnumerable.Sequence(start, stop); Assert.That(start, Is.EqualTo(result.Single())); } diff --git a/MoreLinq.Test/TraceTest.cs b/MoreLinq.Test/TraceTest.cs index 6e32ba55e..e0604a2cb 100644 --- a/MoreLinq.Test/TraceTest.cs +++ b/MoreLinq.Test/TraceTest.cs @@ -67,8 +67,8 @@ public void TraceSequenceWithFormatter() var trace = Lines(CaptureTrace(delegate { var formatter = CultureInfo.InvariantCulture; - new int?[] { 1234, null, 5678 }.Trace(n => n.HasValue - ? n.Value.ToString("N0", formatter) + new int?[] { 1234, null, 5678 }.Trace(n => n is { } some + ? some.ToString("N0", formatter) : "#NULL") .Consume(); }));