Skip to content

Commit

Permalink
Added suppression attributes for CA2213:DisposableFieldsShouldBeDispo…
Browse files Browse the repository at this point in the history
…sed when TryDispose() extension method is used.

Added missing XML documentation to public members.
  • Loading branch information
sweetlandj committed Jun 22, 2016
1 parent 015f2c3 commit 2816715
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions Source/Platibus.RabbitMQ/MessageReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_reader")]
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus.RabbitMQ/MessageWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public void Dispose()
/// <remarks>
/// This method will not be called more than once
/// </remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_writer")]
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus.SQLite/SQLiteMessageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ protected override Task<IEnumerable<SQLQueuedMessage>> SelectQueuedMessages()
return op.Task;
}

[SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_cancellationTokenSource")]
protected override void Dispose(bool disposing)
{
if (disposing)
Expand Down
3 changes: 3 additions & 0 deletions Source/Platibus/Bus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Principal;
using System.Threading;
Expand Down Expand Up @@ -480,6 +481,8 @@ public void Dispose()
/// of the <paramref name="disposing"/> parameter; managed resources
/// should only be disposed if <paramref name="disposing"/> is <c>true</c>
/// </remarks>
[SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_replyHub")]
[SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_cancellationTokenSource")]
protected virtual void Dispose(bool disposing)
{
_cancellationTokenSource.Cancel();
Expand Down
16 changes: 16 additions & 0 deletions Source/Platibus/EndpointAddressEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ namespace Platibus
/// </summary>
public class EndpointAddressEqualityComparer : IEqualityComparer<Uri>
{
/// <summary>
/// Determines whether the specified endpoint address URIs are equal.
/// </summary>
/// <returns>
/// true if the specified URIs are equal; otherwise, false.
/// </returns>
/// <param name="x">The first endpoint address URI to compare.</param>
/// <param name="y">The second endpoint address URI to compare.</param>
public bool Equals(Uri x, Uri y)
{
if (ReferenceEquals(x, y)) return true;
Expand All @@ -19,6 +27,14 @@ public bool Equals(Uri x, Uri y)
StringComparison.OrdinalIgnoreCase);
}

/// <summary>
/// Returns a hash code for the specified object.
/// </summary>
/// <returns>
/// A hash code for the specified object.
/// </returns>
/// <param name="obj">The <see cref="T:System.Object"/> for which a hash code is to be returned.</param>
/// <exception cref="T:System.ArgumentNullException">The type of <paramref name="obj"/> is a reference type and <paramref name="obj"/> is null.</exception>
public int GetHashCode(Uri obj)
{
return obj == null ? 0 : obj
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus/Filesystem/FilesystemMessageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_cancellationTokenSource")]
protected virtual void Dispose(bool disposing)
{
_cancellationTokenSource.Cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public void Dispose()
/// <remarks>
/// This method will not be called more than once
/// </remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_fileAccess")]
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus/Filesystem/MessageFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_fileAccess")]
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus/Filesystem/MessageFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_reader")]
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus/Filesystem/MessageFileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_writer")]
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down
14 changes: 10 additions & 4 deletions Source/Platibus/Http/HttpTransportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,12 @@ private async Task SendSubscriptionRequest(IEndpoint endpoint, TopicName topic,
{
if (endpoint == null) throw new ArgumentNullException("endpoint");
if (topic == null) throw new ArgumentNullException("topic");


HttpClient httpClient = null;
try
{
var endpointBaseUri = endpoint.Address.WithTrailingSlash();
var httpClient = GetClient(endpointBaseUri, endpoint.Credentials);
var endpointBaseUri = endpoint.Address.WithTrailingSlash();
httpClient = GetClient(endpointBaseUri, endpoint.Credentials);

var urlSafeTopicName = HttpUtility.UrlEncode(topic);
var relativeUri = string.Format("topic/{0}/subscriber?uri={1}", urlSafeTopicName, _baseUri);
Expand All @@ -379,7 +380,8 @@ private async Task SendSubscriptionRequest(IEndpoint endpoint, TopicName topic,
relativeUri += "&ttl=" + ttl.TotalSeconds;
}

var httpResponseMessage = await httpClient.PostAsync(relativeUri, new StringContent(""), cancellationToken);
var httpResponseMessage =
await httpClient.PostAsync(relativeUri, new StringContent(""), cancellationToken);
HandleHttpErrorResponse(httpResponseMessage);
}
catch (TransportException)
Expand All @@ -400,6 +402,10 @@ private async Task SendSubscriptionRequest(IEndpoint endpoint, TopicName topic,

throw new TransportException(errorMessage, ex);
}
finally
{
httpClient.TryDispose();
}
}

private static void HandleHttpErrorResponse(HttpResponseMessage response)
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus/InMemory/InMemoryQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_cancellationTokenSource")]
protected virtual void Dispose(bool disposing)
{
_cancellationTokenSource.Cancel();
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus/MemoryCacheReplyHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void Dispose()
/// <remarks>
/// This method will not be called more than once
/// </remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_cache")]
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down
1 change: 1 addition & 0 deletions Source/Platibus/SQL/SQLMessageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ public void Dispose()
/// </summary>
/// <param name="disposing">Indicates whether this method is called from the
/// <see cref="Dispose()"/> method (<c>true</c>) or from the finalizer (<c>false</c>)</param>
[SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_cancellationTokenSource")]
protected virtual void Dispose(bool disposing)
{
_cancellationTokenSource.Cancel();
Expand Down

0 comments on commit 2816715

Please sign in to comment.