Skip to content

Commit

Permalink
Fix CA1816 warnings (#2317)
Browse files Browse the repository at this point in the history
Contributes to #1290.
  • Loading branch information
gabidabet authored Sep 29, 2024
1 parent 856bfdf commit 25e57e4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Polly/Bulkhead/AsyncBulkheadPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void Dispose()
{
_maxParallelizationSemaphore.Dispose();
_maxQueuedActionsSemaphore.Dispose();
GC.SuppressFinalize(this);
}
}

Expand Down Expand Up @@ -123,5 +124,6 @@ public void Dispose()
{
_maxParallelizationSemaphore.Dispose();
_maxQueuedActionsSemaphore.Dispose();
GC.SuppressFinalize(this);
}
}
2 changes: 2 additions & 0 deletions src/Polly/Bulkhead/BulkheadPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void Dispose()
{
_maxParallelizationSemaphore.Dispose();
_maxQueuedActionsSemaphore.Dispose();
GC.SuppressFinalize(this);
}
}

Expand Down Expand Up @@ -118,5 +119,6 @@ public void Dispose()
{
_maxParallelizationSemaphore.Dispose();
_maxQueuedActionsSemaphore.Dispose();
GC.SuppressFinalize(this);
}
}
2 changes: 1 addition & 1 deletion src/Polly/Polly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectType>Library</ProjectType>
<MutationScore>70</MutationScore>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);CA1010;CA1031;CA1051;CA1063;CA1064;CA1724;CA1816;</NoWarn>
<NoWarn>$(NoWarn);CA1010;CA1031;CA1051;CA1063;CA1064;CA1724;</NoWarn>
<NoWarn>$(NoWarn);S2223;S3215;S4039</NoWarn>
<!--Public API Analyzers: We do not need to fix these as it would break compatibility with released Polly versions-->
<NoWarn>$(NoWarn);RS0037;</NoWarn>
Expand Down
4 changes: 4 additions & 0 deletions src/Polly/Utilities/TimedLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ private static TimedLock Lock(object o, TimeSpan timeout)
#if DEBUG
#pragma warning disable S3234 // "GC.SuppressFinalize" should not be invoked for types without destructors
#pragma warning disable S3971 // Do not call 'GC.SuppressFinalize'
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
GC.SuppressFinalize(tl._leakDetector);
#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize
#pragma warning restore S3971
#pragma warning restore S3234
#endif
Expand Down Expand Up @@ -64,7 +66,9 @@ public void Dispose()
// finalizer.
#if DEBUG
#pragma warning disable S3234 // "GC.SuppressFinalize" should not be invoked for types without destructors
#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
GC.SuppressFinalize(_leakDetector);
#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize
#pragma warning restore S3234
#endif
}
Expand Down

0 comments on commit 25e57e4

Please sign in to comment.