Skip to content

Commit 5ceedb5

Browse files
Cleanup and refactor for new analyzers.
1 parent df3b4b4 commit 5ceedb5

18 files changed

+42
-32
lines changed

benchmarking/Benchmarks/CollectionParallelBenchmark.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
using Open.Diagnostics;
22
using System;
33
using System.Collections.Generic;
4-
using System.Diagnostics.CodeAnalysis;
54
using System.Linq;
65
using System.Threading.Tasks;
76

87
namespace Open.Collections
98
{
10-
[SuppressMessage("ReSharper", "ReturnValueOfPureMethodIsNotUsed")]
119
public class CollectionParallelBenchmark<T> : CollectionBenchmark<T>
1210
{
1311
public CollectionParallelBenchmark(uint size, uint repeat, Func<ICollection<T>> factory, Func<int, T> itemFactory) : base(size, repeat, factory, itemFactory)

benchmarking/Benchmarks/LinkedListBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public LinkedListBenchmark(uint size, uint repeat, Func<ILinkedList<object>> fac
1010
{
1111
}
1212

13-
protected readonly object _item = new object();
13+
protected readonly object _item = new();
1414

1515
protected override IEnumerable<TimedResult> TestOnceInternal()
1616
{

benchmarking/Benchmarks/QueueBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public QueueBenchmark(uint size, uint repeat, Func<IQueue<object>> queueFactory)
1010
{
1111
}
1212

13-
protected readonly object _item = new object();
13+
protected readonly object _item = new();
1414

1515
protected override IEnumerable<TimedResult> TestOnceInternal()
1616
{

benchmarking/GlobalSuppressions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "<Pending>", Scope = "member", Target = "~M:Program.OutputList(System.Int32[][])")]
9+
[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "<Pending>", Scope = "member", Target = "~M:Program.QueueTests")]
10+
[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "<Pending>", Scope = "member", Target = "~M:Program.CollectionTests")]
11+
[assembly: SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "<Pending>", Scope = "member", Target = "~M:Program.LinkedListTests")]

benchmarking/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using BenchmarkDotNet.Running;
2-
using Open.Collections;
1+
using Open.Collections;
32
using Open.Collections.Synchronized;
43
using Open.Diagnostics;
54
using System;
@@ -13,7 +12,7 @@ static void Main()
1312
{
1413
Console.Clear();
1514
var perms = new char[] { 'A', 'B', 'C' }.Permutations(new char[3]);
16-
foreach(var p in perms)
15+
foreach (var p in perms)
1716
{
1817
Console.WriteLine(new string(p));
1918
}

source/Extensions.Combinations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public static IEnumerable<T[]> CombinationsBuffered<T>(this IEnumerable<T> eleme
158158
var buffer = pool.Rent(length);
159159
try
160160
{
161-
foreach(var c in Combinations(elements, length, buffer))
161+
foreach (var c in Combinations(elements, length, buffer))
162162
yield return c;
163163
}
164164
finally

source/Extensions.Generic.Synchronized.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static T AddOrUpdateSynchronized<TKey, T>(this IDictionary<TKey, T> targe
142142
() =>
143143
valueUsed = target.AddOrUpdate(key,
144144
newValueFactory,
145-
(k, o) => k!.Equals(key) && (o?.Equals(old) ?? old==null) ? updateValue : updateValueFactory(k, o)
145+
(k, o) => k!.Equals(key) && (o?.Equals(old) ?? old == null) ? updateValue : updateValueFactory(k, o)
146146
));
147147
}
148148
else

source/Extensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Buffers;
33
using System.Collections;
44
using System.Collections.Generic;
5-
using System.Diagnostics.CodeAnalysis;
65
using System.Diagnostics.Contracts;
76
using System.Dynamic;
87
using System.Linq;
@@ -217,7 +216,7 @@ public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> target)
217216
throw new ArgumentNullException(nameof(target));
218217

219218
var r = new Random();
220-
return target.OrderBy(x => (r.Next()));
219+
return target.OrderBy(x => r.Next());
221220
}
222221

223222
// Ensures an optimized means of acquiring Any();
@@ -342,7 +341,7 @@ public static IEnumerable<T> PreCache<T>(this IEnumerable<T> source, int count =
342341
while (queue.Reader.TryRead(out var item))
343342
yield return item;
344343
}
345-
while (queue.Reader.WaitToReadAsync().Result);
344+
while (queue.Reader.WaitToReadAsync().AsTask().Result);
346345

347346
var complete = queue.Reader.Completion;
348347
if (complete.IsFaulted)

source/GlobalSuppressions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("Design", "CA1068:CancellationToken parameters must come last", Justification = "<Pending>", Scope = "member", Target = "~M:Open.Collections.Extensions.ForEach``1(System.Collections.Generic.IEnumerable{``0},System.Threading.CancellationToken,System.Action{``0})")]

source/Open.Collections.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
7+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
78
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
89
<Authors>electricessence</Authors>
910
<Description>

0 commit comments

Comments
 (0)