Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant type spec on obvious new expressions #935

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions MoreLinq.Test/KeyValuePair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace MoreLinq.Test

static class KeyValuePair
{
public static KeyValuePair<TKey, TValue> Create<TKey, TValue>(TKey key, TValue value) =>
new KeyValuePair<TKey, TValue>(key, value);
public static KeyValuePair<TKey, TValue> Create<TKey, TValue>(TKey key, TValue value) => new(key, value);
}
}
2 changes: 1 addition & 1 deletion MoreLinq.Test/ReturnTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<object> Sequence = MoreEnumerable.Return(Item);
public static IList<object> List => (IList<object>)Sequence;
public static ICollection<object> Collection => (ICollection<object>)Sequence;
Expand Down
12 changes: 8 additions & 4 deletions MoreLinq.Test/SampleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ namespace MoreLinq.Test
/// </summary>
static class SampleData
{
internal static readonly ReadOnlyCollection<string> Strings = new ReadOnlyCollection<string>(
new[] { "ax", "hello", "world", "aa", "ab", "ay", "az" });
internal static readonly ReadOnlyCollection<string> Strings = new(new[]
{
"ax", "hello", "world", "aa", "ab", "ay", "az"
});

internal static readonly ReadOnlyCollection<int> Values =
new ReadOnlyCollection<int>(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
internal static readonly ReadOnlyCollection<int> Values = new(new[]
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
});

internal static readonly Func<int, int, int> Plus = (a, b) => a + b;
internal static readonly Func<int, int, int> Mul = (a, b) => a * b;
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq.Test/ShuffleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 3 additions & 7 deletions MoreLinq.Test/ToDataTableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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; }
Expand Down
3 changes: 1 addition & 2 deletions MoreLinq.Test/TraverseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public Tree(T value, IEnumerable<Tree<T>> children)

static class Tree
{
public static Tree<T> New<T>(T value, params Tree<T>[] children) =>
new Tree<T>(value, children);
public static Tree<T> New<T>(T value, params Tree<T>[] children) => new(value, children);
}

[Test]
Expand Down
3 changes: 1 addition & 2 deletions MoreLinq.Test/WatchableEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ namespace MoreLinq.Test

partial class TestExtensions
{
public static WatchableEnumerator<T> AsWatchable<T>(this IEnumerator<T> source) =>
new WatchableEnumerator<T>(source);
public static WatchableEnumerator<T> AsWatchable<T>(this IEnumerator<T> source) => new(source);
}

sealed class WatchableEnumerator<T> : IEnumerator<T>
Expand Down
9 changes: 4 additions & 5 deletions MoreLinq/Experimental/Await.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ public sealed class AwaitQueryOptions
/// asynchronously.
/// </summary>

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);

/// <summary>
/// Gets a positive (non-zero) integer that specifies the maximum
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion MoreLinq/GroupAdjacent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static IGrouping<TKey, TElement> CreateGroupAdjacentGrouping<TKey, TElement>(TKe
static class Grouping
{
public static Grouping<TKey, TElement> Create<TKey, TElement>(TKey key, IEnumerable<TElement> members) =>
new Grouping<TKey, TElement>(key, members);
new(key, members);
}

#if !NO_SERIALIZATION_ATTRIBUTES
Expand Down
3 changes: 1 addition & 2 deletions MoreLinq/Return.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}