Skip to content

Commit d83385e

Browse files
Cleanup and simplification.
1 parent 9fb9271 commit d83385e

11 files changed

+6
-18
lines changed

benchmarking/Benchmark.cs

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

76
#if DEBUG
@@ -10,7 +9,6 @@
109

1110
namespace Open.Disposable.ObjectPools
1211
{
13-
[SuppressMessage("ReSharper", "AccessToDisposedClosure")]
1412
public class Benchmark<T> : BenchmarkBase<Func<IObjectPool<T>>>
1513
where T : class
1614
{

benchmarking/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
using Open.Disposable.ObjectPools;
33
using Open.Text.CSV;
44
using System;
5-
using System.Diagnostics.CodeAnalysis;
65
using System.IO;
76
using System.Text;
87

98
class Program
109
{
11-
[SuppressMessage("ReSharper", "CoVariantArrayConversion")]
1210
static void Main()
1311
{
1412
Console.Write("Initializing...");

source/Array/InterlockedArrayObjectPool.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public InterlockedArrayObjectPool(Func<T> factory, int capacity = DEFAULT_CAPACI
3333
public override int Count
3434
=> Pool.Count(e => e.Value != null) + PocketCount;
3535

36-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Should never be null.")]
3736
protected virtual bool Store(ReferenceContainer<T>[] p, T item, int index)
3837
=> p[index].TrySave(item);
3938

source/Array/OptimisticArrayObjectPool.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ protected override bool SaveToPocket(T item)
2525
=> Pocket.SetIfNull(item);
2626

2727
// As suggested by Roslyn's implementation, don't worry about interlocking here. It's okay if a few get loose.
28-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Should never be null.")]
2928
protected override bool Store(ReferenceContainer<T>[] p, T item, int index)
3029
=> p[index].SetIfNull(item);
3130
}

source/IObjectPool.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Open.Disposable
88
{
9-
[SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")]
109
public interface IObjectPool<T> : IDisposable
1110
where T : class
1211
{

source/ObjectPoolAutoTrimmer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Open.Disposable
66
{
7-
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
87
[SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Micro-optimization for retrieving this value as read-only is slightly slower")]
98
public class ObjectPoolAutoTrimmer : DisposableBase
109
{

source/Open.Disposable.ObjectPools.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
<RootNamespace>Open.Disposable</RootNamespace>
89
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
910
<Authors>electricessence</Authors>

source/Recycler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public static Recycler<T> CreateRecycler<T>(
6060
Action<T> recycleFunction,
6161
ushort limit = Constants.DEFAULT_CAPACITY)
6262
where T : class
63-
=> new Recycler<T>(pool, recycleFunction, limit);
63+
=> new(pool, recycleFunction, limit);
6464

6565
public static Recycler<T> CreateRecycler<T>(
6666
this IObjectPool<T> pool,
6767
ushort limit,
6868
Action<T> recycleFunction)
6969
where T : class
70-
=> new Recycler<T>(pool, recycleFunction, limit);
70+
=> new(pool, recycleFunction, limit);
7171

7272
public static void Recycle(IRecyclable r)
7373
=> (r ?? throw new ArgumentNullException(nameof(r))).Recycle();
@@ -76,6 +76,6 @@ public static Recycler<T> CreateRecycler<T>(
7676
this IObjectPool<T> pool,
7777
ushort limit = Constants.DEFAULT_CAPACITY)
7878
where T : class, IRecyclable
79-
=> new Recycler<T>(pool, Recycle, limit);
79+
=> new(pool, Recycle, limit);
8080
}
8181
}

source/RecyclerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected RecyclerBase(
2222
Target = target ?? throw new ArgumentNullException(nameof(target));
2323
Contract.EndContractBlock();
2424

25-
if (!(target is DisposableBase d)) return;
25+
if (target is not DisposableBase d) return;
2626
if (d.WasDisposed) throw new ArgumentException("Cannot recycle for an object pool that is already disposed.");
2727
d.BeforeDispose += Pool_BeforeDispose;
2828
// Could possibly dispose before this line somewhere... But that's just nasty. :P

source/ReferenceContainer.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System.Diagnostics;
2-
using System.Diagnostics.CodeAnalysis;
32
using System.Threading;
43

54
namespace Open.Disposable
65
{
7-
[SuppressMessage("ReSharper", "UnusedMemberInSuper.Global")]
86
public interface IReferenceContainer<T>
97
where T : class
108
{
@@ -15,7 +13,6 @@ public interface IReferenceContainer<T>
1513
}
1614

1715
[DebuggerDisplay("{Value,nq}")]
18-
[SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Undesired.")]
1916
public struct ReferenceContainer<T> : IReferenceContainer<T>
2017
where T : class
2118
{

0 commit comments

Comments
 (0)