Skip to content

Commit 5d622da

Browse files
Improved disposal pattern.
1 parent 2230a17 commit 5d622da

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Extensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Collections.Concurrent;
55
using System.Collections.Generic;
66
using System.Diagnostics;
7-
using System.Diagnostics.CodeAnalysis;
87
using System.Diagnostics.Contracts;
98
using System.Linq;
109
using System.Threading.Tasks;
@@ -16,7 +15,6 @@ public static class Extensions
1615
/// <summary>
1716
/// Debug utility for asserting if a collection is equal.
1817
/// </summary>
19-
[SuppressMessage("ReSharper", "HeuristicUnreachableCode")]
2018
public static void AssertEquality<TKey, TValue>(this IDictionary<TKey, TValue> target, IDictionary<TKey, TValue> copy)
2119
where TValue : IComparable
2220
{

Open.Collections.Numeric.csproj

Lines changed: 2 additions & 1 deletion
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>
@@ -16,7 +17,7 @@
1617
<PackageProjectUrl>https://github.com/Open-NET-Libraries/Open.Collections.Numeric/</PackageProjectUrl>
1718
<RepositoryUrl>https://github.com/Open-NET-Libraries/Open.Collections.Numeric/</RepositoryUrl>
1819
<RepositoryType>git</RepositoryType>
19-
<Version>1.5.0</Version>
20+
<Version>1.5.1</Version>
2021
<PackageReleaseNotes></PackageReleaseNotes>
2122
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2223
<PublishRepositoryUrl>true</PublishRepositoryUrl>

PossibleAddends.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using System;
1+
using Open.Disposable;
2+
using System;
23
using System.Collections.Concurrent;
34
using System.Collections.Generic;
45
using System.Collections.Immutable;
56

67
namespace Open.Collections.Numeric
78
{
8-
public class PossibleAddends : IDisposable
9+
public class PossibleAddends : DisposableBase
910
{
1011
public PossibleAddends()
1112
{
@@ -22,11 +23,11 @@ public IEnumerable<IReadOnlyList<int>> GetUniqueAddends(int sum, int count)
2223
{
2324
if (count > int.MaxValue)
2425
throw new ArgumentOutOfRangeException(nameof(count), count, "Cannot be greater than signed 32 bit integer maximum.");
25-
if(count<2 || sum < 3)
26+
if (count < 2 || sum < 3)
2627
yield break;
2728

2829

29-
if (count==2)
30+
if (count == 2)
3031
{
3132
int i = 0;
3233
loop2:
@@ -57,6 +58,6 @@ public IEnumerable<IReadOnlyList<int>> GetUniqueAddends(int sum, int count)
5758
}
5859
}
5960

60-
public void Dispose() => Cache.Clear();
61+
protected override void OnDispose() => Cache.Clear();
6162
}
6263
}

0 commit comments

Comments
 (0)