diff --git a/MoreLinq.Test/KeyValuePair.cs b/MoreLinq.Test/KeyValuePair.cs index ee9a44dc0..82493f0d0 100644 --- a/MoreLinq.Test/KeyValuePair.cs +++ b/MoreLinq.Test/KeyValuePair.cs @@ -21,7 +21,6 @@ namespace MoreLinq.Test static class KeyValuePair { - public static KeyValuePair Create(TKey key, TValue value) => - new KeyValuePair(key, value); + public static KeyValuePair Create(TKey key, TValue value) => new(key, value); } } diff --git a/MoreLinq.Test/ReturnTest.cs b/MoreLinq.Test/ReturnTest.cs index 21e1b4bea..fda98990b 100644 --- a/MoreLinq.Test/ReturnTest.cs +++ b/MoreLinq.Test/ReturnTest.cs @@ -26,7 +26,7 @@ public class ReturnTest { static class SomeSingleton { - public static readonly object Item = new object(); + public static readonly object Item = new(); public static readonly IEnumerable Sequence = MoreEnumerable.Return(Item); public static IList List => (IList)Sequence; public static ICollection Collection => (ICollection)Sequence; diff --git a/MoreLinq.Test/SampleData.cs b/MoreLinq.Test/SampleData.cs index df74bed9b..6e257d060 100644 --- a/MoreLinq.Test/SampleData.cs +++ b/MoreLinq.Test/SampleData.cs @@ -25,11 +25,15 @@ namespace MoreLinq.Test /// static class SampleData { - internal static readonly ReadOnlyCollection Strings = new ReadOnlyCollection( - new[] { "ax", "hello", "world", "aa", "ab", "ay", "az" }); + internal static readonly ReadOnlyCollection Strings = new(new[] + { + "ax", "hello", "world", "aa", "ab", "ay", "az" + }); - internal static readonly ReadOnlyCollection Values = - new ReadOnlyCollection(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + internal static readonly ReadOnlyCollection Values = new(new[] + { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + }); internal static readonly Func Plus = (a, b) => a + b; internal static readonly Func Mul = (a, b) => a * b; diff --git a/MoreLinq.Test/ShuffleTest.cs b/MoreLinq.Test/ShuffleTest.cs index cd9769d86..eeb82edc0 100644 --- a/MoreLinq.Test/ShuffleTest.cs +++ b/MoreLinq.Test/ShuffleTest.cs @@ -23,7 +23,7 @@ namespace MoreLinq.Test [TestFixture] public class ShuffleTest { - static Random seed = new Random(12345); + static Random seed = new(12345); [Test] public void ShuffleIsLazy() diff --git a/MoreLinq.Test/ToDataTableTest.cs b/MoreLinq.Test/ToDataTableTest.cs index e3696b222..e800dd7c0 100644 --- a/MoreLinq.Test/ToDataTableTest.cs +++ b/MoreLinq.Test/ToDataTableTest.cs @@ -38,12 +38,7 @@ sealed class TestObject public decimal? ANullableDecimal { get; } public object Unreadable { set => throw new NotImplementedException(); } - public object this[int index] - { - get => new object(); - set { } - } - + public object this[int index] { get => new(); set { } } public TestObject(int key) { @@ -192,8 +187,9 @@ public void ToDataTableWithSchema() struct Point { + #pragma warning disable CA1805 // Do not initialize unnecessarily (avoids CS0649) - public static Point Empty = new Point(); + public static Point Empty = new(); #pragma warning restore CA1805 // Do not initialize unnecessarily public bool IsEmpty => X == 0 && Y == 0; public int X { get; } diff --git a/MoreLinq.Test/TraverseTest.cs b/MoreLinq.Test/TraverseTest.cs index 3b9235e9b..07736d9ac 100644 --- a/MoreLinq.Test/TraverseTest.cs +++ b/MoreLinq.Test/TraverseTest.cs @@ -64,8 +64,7 @@ public Tree(T value, IEnumerable> children) static class Tree { - public static Tree New(T value, params Tree[] children) => - new Tree(value, children); + public static Tree New(T value, params Tree[] children) => new(value, children); } [Test] diff --git a/MoreLinq.Test/WatchableEnumerator.cs b/MoreLinq.Test/WatchableEnumerator.cs index 2756df448..cb6b14bef 100644 --- a/MoreLinq.Test/WatchableEnumerator.cs +++ b/MoreLinq.Test/WatchableEnumerator.cs @@ -23,8 +23,7 @@ namespace MoreLinq.Test partial class TestExtensions { - public static WatchableEnumerator AsWatchable(this IEnumerator source) => - new WatchableEnumerator(source); + public static WatchableEnumerator AsWatchable(this IEnumerator source) => new(source); } sealed class WatchableEnumerator : IEnumerator diff --git a/MoreLinq/Experimental/Await.cs b/MoreLinq/Experimental/Await.cs index 92a00bbc0..54433155b 100644 --- a/MoreLinq/Experimental/Await.cs +++ b/MoreLinq/Experimental/Await.cs @@ -40,10 +40,9 @@ public sealed class AwaitQueryOptions /// asynchronously. /// - public static readonly AwaitQueryOptions Default = - new AwaitQueryOptions(null /* = unbounded concurrency */, - TaskScheduler.Default, - preserveOrder: false); + public static readonly AwaitQueryOptions Default = new(null /* = unbounded concurrency */, + TaskScheduler.Default, + preserveOrder: false); /// /// Gets a positive (non-zero) integer that specifies the maximum @@ -766,7 +765,7 @@ static Task CreateCompletedTask() sealed class ConcurrencyGate { - public static readonly ConcurrencyGate Unbounded = new ConcurrencyGate(); + public static readonly ConcurrencyGate Unbounded = new(); readonly SemaphoreSlim? _semaphore; diff --git a/MoreLinq/GroupAdjacent.cs b/MoreLinq/GroupAdjacent.cs index 08bd069a6..162d23735 100644 --- a/MoreLinq/GroupAdjacent.cs +++ b/MoreLinq/GroupAdjacent.cs @@ -301,7 +301,7 @@ static IGrouping CreateGroupAdjacentGrouping(TKe static class Grouping { public static Grouping Create(TKey key, IEnumerable members) => - new Grouping(key, members); + new(key, members); } #if !NO_SERIALIZATION_ATTRIBUTES diff --git a/MoreLinq/Return.cs b/MoreLinq/Return.cs index 810ecd385..35ffa3adc 100644 --- a/MoreLinq/Return.cs +++ b/MoreLinq/Return.cs @@ -63,8 +63,7 @@ public T this[int index] public void Insert(int index, T item) => throw ReadOnlyException(); public void RemoveAt(int index) => throw ReadOnlyException(); - static NotSupportedException ReadOnlyException() => - new NotSupportedException("Single element list is immutable."); + static NotSupportedException ReadOnlyException() => new("Single element list is immutable."); } } }