From 56b9467601c22dacb396da49e6022afd2946a020 Mon Sep 17 00:00:00 2001 From: Stuart Turner Date: Thu, 11 Apr 2024 13:14:32 -0500 Subject: [PATCH] Address code warnings from net9 preview.3 (#648) --- .editorconfig | 1 - Source/SuperLinq/Memoize.cs | 1 + Source/SuperLinq/WindowLeft.cs | 3 +++ Tests/SuperLinq.Test/ToArrayByIndexTest.cs | 5 ++++- Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2d759694..1755af05 100644 --- a/.editorconfig +++ b/.editorconfig @@ -270,7 +270,6 @@ dotnet_diagnostic.IDE0043.severity = error # IDE0043: Format string dotnet_diagnostic.IDE0051.severity = warning # IDE0051: Remove unused private member dotnet_diagnostic.IDE0052.severity = warning # IDE0052: Remove unread private member dotnet_diagnostic.IDE0076.severity = warning # IDE0076: Remove invalid global 'SuppressMessageAttribute' -dotnet_diagnostic.IDE0305.severity = suggestion # IDE0305: Simplify collection initialization # XML Documentation dotnet_diagnostic.CS0105.severity = error # CS0105: Using directive is unnecessary. diff --git a/Source/SuperLinq/Memoize.cs b/Source/SuperLinq/Memoize.cs index 9fb12ad8..6031f5cf 100644 --- a/Source/SuperLinq/Memoize.cs +++ b/Source/SuperLinq/Memoize.cs @@ -281,6 +281,7 @@ public IEnumerator GetEnumerator() return GetEnumeratorImpl(buffer); } + [SuppressMessage("Style", "IDE0305:Simplify collection initialization")] private T[] InitializeBuffer() { var source = _source; diff --git a/Source/SuperLinq/WindowLeft.cs b/Source/SuperLinq/WindowLeft.cs index 2e38bbca..adc42ba1 100644 --- a/Source/SuperLinq/WindowLeft.cs +++ b/Source/SuperLinq/WindowLeft.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace SuperLinq; public static partial class SuperEnumerable @@ -93,6 +95,7 @@ int size { public override int Count => source.Count; + [SuppressMessage("Style", "IDE0305:Simplify collection initialization")] protected override IEnumerable> GetEnumerable() { T[] window; diff --git a/Tests/SuperLinq.Test/ToArrayByIndexTest.cs b/Tests/SuperLinq.Test/ToArrayByIndexTest.cs index 50c90832..86dd9d41 100644 --- a/Tests/SuperLinq.Test/ToArrayByIndexTest.cs +++ b/Tests/SuperLinq.Test/ToArrayByIndexTest.cs @@ -1,4 +1,6 @@ -namespace Test; +using System.Diagnostics.CodeAnalysis; + +namespace Test; public sealed class ToArrayByIndexTest { @@ -17,6 +19,7 @@ public sealed class ToArrayByIndexTest [InlineData(true, new[] { 0, 5, 9 })] [InlineData(true, new[] { 2, 3, 5, 9 })] [InlineData(true, new[] { 5, 2, 9, 3 })] + [SuppressMessage("Style", "IDE0305:Simplify collection initialization")] public void ToArrayByIndex(bool withLength, int[] indices) { using var input = indices diff --git a/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs b/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs index 2e650b71..bf68f28d 100644 --- a/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs +++ b/Tests/SuperLinq.Test/UpdatablePriorityQueueTest.cs @@ -247,8 +247,8 @@ public void UpdatablePriorityQueue_Enumeration_OrderingIsConsistent(int count) { var queue = CreateUpdatablePriorityQueue(initialCapacity: 0, count, out _); - (TElement, TPriority)[] firstEnumeration = queue.UnorderedItems.ToArray(); - (TElement, TPriority)[] secondEnumeration = queue.UnorderedItems.ToArray(); + var firstEnumeration = queue.UnorderedItems.ToArray(); + var secondEnumeration = queue.UnorderedItems.ToArray(); Assert.Equal(firstEnumeration.Length, count); Assert.True(firstEnumeration.SequenceEqual(secondEnumeration));