Skip to content

Commit ab36f9b

Browse files
committed
more style cleanup taken over from other pull request
1 parent fd1bb55 commit ab36f9b

33 files changed

+59
-58
lines changed

projects/RabbitMQ.Client/client/api/AmqpTcpEndpoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public static AmqpTcpEndpoint Parse(string address)
222222
/// </remarks>
223223
public static AmqpTcpEndpoint[] ParseMultiple(string addresses)
224224
{
225-
string[] partsArr = addresses.Split(new[] {','});
225+
string[] partsArr = addresses.Split(',');
226226
var results = new List<AmqpTcpEndpoint>();
227227
foreach (string partRaw in partsArr)
228228
{

projects/RabbitMQ.Client/client/api/ExternalMechanism.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
3030
//---------------------------------------------------------------------------
3131

32+
using System;
33+
3234
namespace RabbitMQ.Client
3335
{
3436
public class ExternalMechanism : IAuthMechanism
@@ -38,7 +40,7 @@ public class ExternalMechanism : IAuthMechanism
3840
/// </summary>
3941
public byte[] handleChallenge(byte[] challenge, IConnectionFactory factory)
4042
{
41-
return new byte[0];
43+
return Array.Empty<byte>();
4244
}
4345
}
4446
}

projects/RabbitMQ.Client/client/api/IEndpointResolverExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public static T SelectOne<T>(this IEndpointResolver resolver, Func<AmqpTcpEndpoi
4040
{
4141
var t = default(T);
4242
var exceptions = new List<Exception>();
43-
foreach(AmqpTcpEndpoint ep in resolver.All())
43+
foreach (AmqpTcpEndpoint ep in resolver.All())
4444
{
4545
try
4646
{
4747
t = selector(ep);
48-
if(t.Equals(default(T)) == false)
48+
if (t.Equals(default(T)) == false)
4949
{
5050
return t;
5151
}
@@ -56,12 +56,12 @@ public static T SelectOne<T>(this IEndpointResolver resolver, Func<AmqpTcpEndpoi
5656
}
5757
}
5858

59-
if(Object.Equals(t, default(T)) && exceptions.Count > 0)
59+
if (Object.Equals(t, default(T)) && exceptions.Count > 0)
6060
{
6161
throw new AggregateException(exceptions);
6262
}
6363

6464
return t;
6565
}
6666
}
67-
}
67+
}

projects/RabbitMQ.Client/client/events/AsyncEventHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ internal static class AsyncEventHandlerExtensions
99
{
1010
public static async Task InvokeAsync<TEvent>(this AsyncEventHandler<TEvent> eventHandler, object sender, TEvent @event) where TEvent : EventArgs
1111
{
12-
if(eventHandler != null)
12+
if (eventHandler != null)
1313
{
14-
foreach(AsyncEventHandler<TEvent> handlerInstance in eventHandler.GetInvocationList())
14+
foreach (AsyncEventHandler<TEvent> handlerInstance in eventHandler.GetInvocationList())
1515
{
1616
await handlerInstance(sender, @event).ConfigureAwait(false);
1717
}

projects/RabbitMQ.Client/client/impl/AmqpVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace RabbitMQ.Client.Framing.Impl
4545
/// special-cases 8-0, rewriting it at construction time to be 0-8 instead.
4646
/// </para>
4747
/// </remarks>
48-
class AmqpVersion
48+
internal class AmqpVersion
4949
{
5050
/// <summary>
5151
/// Construct an <see cref="AmqpVersion"/> from major and minor version numbers.

projects/RabbitMQ.Client/client/impl/AsyncConsumerWorkService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public Task Stop(IModel model)
4646
return Task.CompletedTask;
4747
}
4848

49-
class WorkPool
49+
private class WorkPool
5050
{
51-
readonly Channel<Work> _channel;
52-
readonly IModel _model;
51+
private readonly Channel<Work> _channel;
52+
private readonly IModel _model;
5353
private Task _worker;
5454
private readonly int _concurrency;
5555
private SemaphoreSlim _limiter;

projects/RabbitMQ.Client/client/impl/AutorecoveringModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ public IBasicPublishBatch CreateBasicPublishBatch()
18281828
throw new ObjectDisposedException(GetType().FullName);
18291829
}
18301830

1831-
return ((IFullModel)_delegate).CreateBasicPublishBatch();
1831+
return _delegate.CreateBasicPublishBatch();
18321832
}
18331833

18341834
public IBasicPublishBatch CreateBasicPublishBatch(int sizeHint)
@@ -1838,7 +1838,7 @@ public IBasicPublishBatch CreateBasicPublishBatch(int sizeHint)
18381838
throw new ObjectDisposedException(GetType().FullName);
18391839
}
18401840

1841-
return ((IFullModel)_delegate).CreateBasicPublishBatch(sizeHint);
1841+
return _delegate.CreateBasicPublishBatch(sizeHint);
18421842
}
18431843
}
18441844
}

projects/RabbitMQ.Client/client/impl/BasicProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
namespace RabbitMQ.Client.Impl
3535
{
36-
abstract class BasicProperties : ContentHeaderBase, IBasicProperties
36+
internal abstract class BasicProperties : ContentHeaderBase, IBasicProperties
3737
{
3838
/// <summary>
3939
/// Application Id.

projects/RabbitMQ.Client/client/impl/Connection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ internal OutgoingCommand ChannelCloseWrapper(ushort reasonCode, string reasonTex
10431043
return request;
10441044
}
10451045

1046-
void StartAndTune()
1046+
private void StartAndTune()
10471047
{
10481048
var connectionStartCell = new BlockingCell<ConnectionStartDetails>();
10491049
_model0.m_connectionStartCell = connectionStartCell;

projects/RabbitMQ.Client/client/impl/ConnectionStartDetails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
namespace RabbitMQ.Client.Impl
3535
{
36-
class ConnectionStartDetails
36+
internal class ConnectionStartDetails
3737
{
3838
public byte[] m_locales;
3939
public byte[] m_mechanisms;

projects/RabbitMQ.Client/client/impl/ConsumerWorkService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ internal Task StopWorkAsync(IModel model)
6060
return Task.CompletedTask;
6161
}
6262

63-
class WorkPool
63+
private class WorkPool
6464
{
6565
private readonly Channel<Action> _channel;
6666
private readonly int _concurrency;
6767
private Task _worker;
68-
CancellationTokenSource _tokenSource;
68+
private CancellationTokenSource _tokenSource;
6969
private SemaphoreSlim _limiter;
7070

7171
public WorkPool(int concurrency)
@@ -93,7 +93,7 @@ public void Enqueue(Action action)
9393
_channel.Writer.TryWrite(action);
9494
}
9595

96-
async Task Loop()
96+
private async Task Loop()
9797
{
9898
while (await _channel.Reader.WaitToReadAsync().ConfigureAwait(false))
9999
{
@@ -111,7 +111,7 @@ async Task Loop()
111111
}
112112
}
113113

114-
async Task LoopWithConcurrency(CancellationToken cancellationToken)
114+
private async Task LoopWithConcurrency(CancellationToken cancellationToken)
115115
{
116116
try
117117
{
@@ -135,7 +135,7 @@ async Task LoopWithConcurrency(CancellationToken cancellationToken)
135135
}
136136
}
137137

138-
static async Task OffloadToWorkerThreadPool(Action action, SemaphoreSlim limiter)
138+
private static async Task OffloadToWorkerThreadPool(Action action, SemaphoreSlim limiter)
139139
{
140140
try
141141
{

projects/RabbitMQ.Client/client/impl/IConsumerDispatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
namespace RabbitMQ.Client.Impl
3636
{
37-
interface IConsumerDispatcher
37+
internal interface IConsumerDispatcher
3838
{
3939
bool IsShutdown { get; }
4040

projects/RabbitMQ.Client/client/impl/IFrameHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
namespace RabbitMQ.Client.Impl
3636
{
37-
interface IFrameHandler
37+
internal interface IFrameHandler
3838
{
3939
AmqpTcpEndpoint Endpoint { get; }
4040

projects/RabbitMQ.Client/client/impl/IProtocolExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
namespace RabbitMQ.Client.Framing.Impl
3939
{
40-
static class IProtocolExtensions
40+
internal static class IProtocolExtensions
4141
{
4242
public static IFrameHandler CreateFrameHandler(
4343
this IProtocol protocol,

projects/RabbitMQ.Client/client/impl/IRpcContinuation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
namespace RabbitMQ.Client.Impl
3333
{
34-
interface IRpcContinuation
34+
internal interface IRpcContinuation
3535
{
3636
void HandleCommand(in IncomingCommand cmd);
3737
void HandleModelShutdown(ShutdownEventArgs reason);

projects/RabbitMQ.Client/client/impl/MethodBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
namespace RabbitMQ.Client.Impl
3333
{
34-
abstract class MethodBase : IMethod
34+
internal abstract class MethodBase : IMethod
3535
{
3636
public abstract bool HasContent { get; }
3737

projects/RabbitMQ.Client/client/impl/ModelBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
namespace RabbitMQ.Client.Impl
4747
{
48-
abstract class ModelBase : IFullModel, IRecoverable
48+
internal abstract class ModelBase : IFullModel, IRecoverable
4949
{
5050
///<summary>Only used to kick-start a connection open
5151
///sequence. See <see cref="Connection.Open"/> </summary>

projects/RabbitMQ.Client/client/impl/RpcContinuationQueue.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace RabbitMQ.Client.Impl
4343
/// under a somewhat generous reading.
4444
///</para>
4545
///</remarks>
46-
class RpcContinuationQueue
46+
internal class RpcContinuationQueue
4747
{
4848
private class EmptyRpcContinuation : IRpcContinuation
4949
{
@@ -55,8 +55,9 @@ public void HandleModelShutdown(ShutdownEventArgs reason)
5555
{
5656
}
5757
}
58-
static readonly EmptyRpcContinuation s_tmp = new EmptyRpcContinuation();
59-
IRpcContinuation _outstandingRpc = s_tmp;
58+
59+
private static readonly EmptyRpcContinuation s_tmp = new EmptyRpcContinuation();
60+
private IRpcContinuation _outstandingRpc = s_tmp;
6061

6162
///<summary>Enqueue a continuation, marking a pending RPC.</summary>
6263
///<remarks>

projects/RabbitMQ.Client/client/impl/SessionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
namespace RabbitMQ.Client.Impl
3838
{
39-
class SessionManager
39+
internal class SessionManager
4040
{
4141
public readonly ushort ChannelMax;
4242
private readonly IntAllocator _ints;

projects/RabbitMQ.Client/client/impl/ShutdownContinuation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
namespace RabbitMQ.Client.Impl
3737
{
38-
class ShutdownContinuation
38+
internal class ShutdownContinuation
3939
{
4040
public readonly BlockingCell<ShutdownEventArgs> m_cell = new BlockingCell<ShutdownEventArgs>();
4141

projects/RabbitMQ.Client/client/impl/SimpleBlockingRpcContinuation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
namespace RabbitMQ.Client.Impl
3737
{
38-
class SimpleBlockingRpcContinuation : IRpcContinuation
38+
internal class SimpleBlockingRpcContinuation : IRpcContinuation
3939
{
4040
public readonly BlockingCell<Either<IncomingCommand, ShutdownEventArgs>> m_cell = new BlockingCell<Either<IncomingCommand, ShutdownEventArgs>>();
4141

projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static async Task TimeoutAfter(this Task task, TimeSpan timeout)
6060
}
6161
}
6262

63-
class SocketFrameHandler : IFrameHandler
63+
internal class SocketFrameHandler : IFrameHandler
6464
{
6565
// Socket poll timeout in ms. If the socket does not
6666
// become writeable in this amount of time, we throw

projects/RabbitMQ.Client/client/impl/SslHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace RabbitMQ.Client.Impl
4141
/// Represents an <see cref="SslHelper"/> which does the actual heavy lifting to set up an SSL connection,
4242
/// using the config options in an <see cref="SslOption"/> to make things cleaner.
4343
/// </summary>
44-
class SslHelper
44+
internal class SslHelper
4545
{
4646
private readonly SslOption _sslOption;
4747

projects/RabbitMQ.Client/client/impl/StreamProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
namespace RabbitMQ.Client.Impl
3535
{
36-
abstract class StreamProperties : ContentHeaderBase, IStreamProperties
36+
internal abstract class StreamProperties : ContentHeaderBase, IStreamProperties
3737
{
3838
public abstract string ContentEncoding { get; set; }
3939
public abstract string ContentType { get; set; }

projects/RabbitMQ.Client/client/impl/TcpClientAdapter.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace RabbitMQ.Client.Impl
88
/// <summary>
99
/// Simple wrapper around TcpClient.
1010
/// </summary>
11-
class TcpClientAdapter : ITcpClient
11+
internal class TcpClientAdapter : ITcpClient
1212
{
1313
private Socket _sock;
1414

@@ -42,10 +42,7 @@ public virtual async Task ConnectAsync(IPAddress ep, int port)
4242

4343
public virtual void Close()
4444
{
45-
if (_sock != null)
46-
{
47-
_sock.Dispose();
48-
}
45+
_sock?.Dispose();
4946
_sock = null;
5047
}
5148

@@ -84,7 +81,10 @@ public virtual bool Connected
8481
{
8582
get
8683
{
87-
if(_sock == null) return false;
84+
if (_sock is null)
85+
{
86+
return false;
87+
}
8888
return _sock.Connected;
8989
}
9090
}
@@ -105,7 +105,7 @@ public virtual TimeSpan ReceiveTimeout
105105

106106
private void AssertSocket()
107107
{
108-
if(_sock == null)
108+
if (_sock is null)
109109
{
110110
throw new InvalidOperationException("Cannot perform operation as socket is null");
111111
}

projects/RabbitMQ.Client/client/impl/TcpClientAdapterHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace RabbitMQ.Client.Impl
77
{
8-
static class TcpClientAdapterHelper
8+
internal static class TcpClientAdapterHelper
99
{
1010
public static IPAddress GetMatchingHost(IReadOnlyCollection<IPAddress> addresses, AddressFamily addressFamily)
1111
{

projects/RabbitMQ.Client/client/logging/ESLog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
namespace RabbitMQ.Client.Logging
3333
{
34-
static class ESLog
34+
internal static class ESLog
3535
{
3636
public static void Info(string message)
3737
{

projects/RabbitMQ.Client/util/BlockingCell.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace RabbitMQ.Util
4444
///attempts to set Value result in a thrown
4545
///InvalidOperationException.
4646
///</remarks>
47-
class BlockingCell<T>
47+
internal class BlockingCell<T>
4848
{
4949
private readonly ManualResetEventSlim _manualResetEventSlim = new ManualResetEventSlim(false);
5050
private T _value = default;

projects/RabbitMQ.Client/util/DebugUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace RabbitMQ.Util
4040
///<remarks>
4141
///Not part of the public API.
4242
///</remarks>
43-
static class DebugUtil
43+
internal static class DebugUtil
4444
{
4545
///<summary>Print a hex dump of the supplied bytes to stdout.</summary>
4646
public static void Dump(byte[] bytes)

0 commit comments

Comments
 (0)