Skip to content

Commit 12188de

Browse files
committed
make implementations internal and sealed
1 parent 4395cfc commit 12188de

18 files changed

+140
-132
lines changed

projects/client/Apigen/src/apigen/Apigen.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public void EmitPrelude()
443443
public void EmitPublic()
444444
{
445445
EmitLine("namespace " + ApiNamespaceBase + " {");
446-
EmitLine(" public class Protocol: " + ImplNamespaceBase + ".ProtocolBase {");
446+
EmitLine(" internal sealed class Protocol: " + ImplNamespaceBase + ".ProtocolBase {");
447447
EmitLine(" ///<summary>Protocol major version (= " + m_majorVersion + ")</summary>");
448448
EmitLine(" public override int MajorVersion { get { return " + m_majorVersion + "; } }");
449449
EmitLine(" ///<summary>Protocol minor version (= " + m_minorVersion + ")</summary>");
@@ -460,7 +460,7 @@ public void EmitPublic()
460460
EmitLine("");
461461
EmitContentHeaderReader();
462462
EmitLine(" }");
463-
EmitLine(" public class Constants {");
463+
EmitLine(" internal sealed class Constants {");
464464
foreach (KeyValuePair<string, int> de in m_constants)
465465
{
466466
EmitLine(" ///<summary>(= " + de.Value + ")</summary>");
@@ -553,7 +553,7 @@ public void EmitClassProperties(AmqpClass c)
553553
"AMQP specification content header properties for " +
554554
"content class \"" + c.Name + "\"");
555555
EmitSpecComment(c.DocumentationCommentVariant(" ", "remarks"));
556-
EmitLine(" public class " + MangleClass(c.Name)
556+
EmitLine(" internal sealed class " + MangleClass(c.Name)
557557
+ "Properties: " + propertiesBaseClass + " {");
558558
foreach (AmqpField f in c.m_Fields)
559559
{
@@ -714,7 +714,7 @@ public void EmitClassMethodImplementations(AmqpClass c)
714714
{
715715
EmitAutogeneratedSummary(" ",
716716
"Private implementation class - do not use directly.");
717-
EmitLine(" public class " + MangleMethodClass(c, m)
717+
EmitLine(" internal sealed class " + MangleMethodClass(c, m)
718718
+ ": RabbitMQ.Client.Impl.MethodBase, I" + MangleMethodClass(c, m) + " {");
719719
EmitLine(" public const ushort ClassId = " + c.Index + ";");
720720
EmitLine(" public const ushort MethodId = " + m.Index + ";");
@@ -898,7 +898,7 @@ public Attribute Attribute(IEnumerable<object> attributes, Type t)
898898

899899
public void EmitModelImplementation()
900900
{
901-
EmitLine(" public class Model: RabbitMQ.Client.Impl.ModelBase {");
901+
EmitLine(" internal class Model: RabbitMQ.Client.Impl.ModelBase {");
902902
EmitLine(" public Model(RabbitMQ.Client.Impl.ISession session): base(session) {}");
903903
EmitLine(" public Model(RabbitMQ.Client.Impl.ISession session, RabbitMQ.Client.ConsumerWorkService workService): base(session, workService) {}");
904904
IList<MethodInfo> asynchronousHandlers = new List<MethodInfo>();

projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,11 @@
7575
<ItemGroup>
7676
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="4.0.0" PrivateAssets="All" />
7777
</ItemGroup>
78+
79+
<ItemGroup>
80+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
81+
<_Parameter1>Unit</_Parameter1>
82+
</AssemblyAttribute>
83+
</ItemGroup>
84+
7885
</Project>

projects/client/RabbitMQ.Client/src/client/impl/AsyncConsumerDispatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace RabbitMQ.Client.Impl
22
{
3-
internal class AsyncConsumerDispatcher : IConsumerDispatcher
3+
internal sealed class AsyncConsumerDispatcher : IConsumerDispatcher
44
{
55
private readonly ModelBase model;
66
private readonly AsyncConsumerWorkService workService;

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

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

77
namespace RabbitMQ.Client
88
{
9-
internal class AsyncConsumerWorkService : ConsumerWorkService
9+
internal sealed class AsyncConsumerWorkService : ConsumerWorkService
1010
{
1111
readonly ConcurrentDictionary<IModel, WorkPool> workPools = new ConcurrentDictionary<IModel, WorkPool>();
1212

projects/client/RabbitMQ.Client/src/client/impl/AutorecoveringConnection.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050

5151
namespace RabbitMQ.Client.Framing.Impl
5252
{
53-
public class AutorecoveringConnection : IConnection
53+
internal sealed class AutorecoveringConnection : IConnection
5454
{
5555
private readonly object m_eventLock = new object();
5656

5757
private readonly object manuallyClosedLock = new object();
58-
protected Connection m_delegate;
59-
protected ConnectionFactory m_factory;
58+
private Connection m_delegate;
59+
private ConnectionFactory m_factory;
6060

6161
// list of endpoints provided on initial connection.
6262
// on re-connection, the next host in the line is chosen using
@@ -66,7 +66,7 @@ public class AutorecoveringConnection : IConnection
6666
private readonly object m_recordedEntitiesLock = new object();
6767
private readonly TaskFactory recoveryTaskFactory = new TaskFactory();
6868
private readonly object recoveryLockTarget = new object();
69-
// used to block connection recovery attempts after Close() is unvoked
69+
// used to block connection recovery attempts after Close() is invoked
7070
private bool manuallyClosed = false;
7171
private bool performingRecovery = false;
7272

@@ -387,7 +387,7 @@ public void BeginAutomaticRecovery()
387387
}
388388
}
389389

390-
protected void PerformAutomaticRecovery()
390+
private void PerformAutomaticRecovery()
391391
{
392392
ESLog.Info("Performing automatic recovery");
393393
lock (recoveryLockTarget)
@@ -715,7 +715,7 @@ void IDisposable.Dispose()
715715
Dispose(true);
716716
}
717717

718-
protected virtual void Dispose(bool disposing)
718+
private void Dispose(bool disposing)
719719
{
720720
if (disposing)
721721
{
@@ -740,17 +740,17 @@ protected virtual void Dispose(bool disposing)
740740
// dispose unmanaged resources
741741
}
742742

743-
protected void EnsureIsOpen()
743+
private void EnsureIsOpen()
744744
{
745745
m_delegate.EnsureIsOpen();
746746
}
747747

748-
protected void HandleTopologyRecoveryException(TopologyRecoveryException e)
748+
private void HandleTopologyRecoveryException(TopologyRecoveryException e)
749749
{
750750
ESLog.Error("Topology recovery exception", e);
751751
}
752752

753-
protected void PropagateQueueNameChangeToBindings(string oldName, string newName)
753+
private void PropagateQueueNameChangeToBindings(string oldName, string newName)
754754
{
755755
lock (m_recordedBindings)
756756
{
@@ -762,7 +762,7 @@ protected void PropagateQueueNameChangeToBindings(string oldName, string newName
762762
}
763763
}
764764

765-
protected void PropagateQueueNameChangeToConsumers(string oldName, string newName)
765+
private void PropagateQueueNameChangeToConsumers(string oldName, string newName)
766766
{
767767
lock (m_recordedBindings)
768768
{
@@ -775,7 +775,7 @@ protected void PropagateQueueNameChangeToConsumers(string oldName, string newNam
775775
}
776776
}
777777

778-
protected void RecoverBindings()
778+
private void RecoverBindings()
779779
{
780780
foreach (var b in m_recordedBindings.Keys)
781781
{
@@ -792,15 +792,15 @@ protected void RecoverBindings()
792792
}
793793
}
794794

795-
protected void RecoverConnectionBlockedHandlers()
795+
private void RecoverConnectionBlockedHandlers()
796796
{
797797
lock (m_eventLock)
798798
{
799799
m_delegate.ConnectionBlocked += m_recordedBlockedEventHandlers;
800800
}
801801
}
802802

803-
protected bool RecoverConnectionDelegate()
803+
private bool RecoverConnectionDelegate()
804804
{
805805
while (!ManuallyClosed)
806806
{
@@ -844,17 +844,17 @@ protected bool RecoverConnectionDelegate()
844844
return false;
845845
}
846846

847-
protected void RecoverConnectionShutdownHandlers()
847+
private void RecoverConnectionShutdownHandlers()
848848
{
849849
m_delegate.ConnectionShutdown += m_recordedShutdownEventHandlers;
850850
}
851851

852-
protected void RecoverConnectionUnblockedHandlers()
852+
private void RecoverConnectionUnblockedHandlers()
853853
{
854854
m_delegate.ConnectionUnblocked += m_recordedUnblockedEventHandlers;
855855
}
856856

857-
protected void RecoverConsumers()
857+
private void RecoverConsumers()
858858
{
859859
foreach (KeyValuePair<string, RecordedConsumer> pair in m_recordedConsumers)
860860
{
@@ -898,7 +898,7 @@ protected void RecoverConsumers()
898898
}
899899
}
900900

901-
protected void RecoverEntities()
901+
private void RecoverEntities()
902902
{
903903
// The recovery sequence is the following:
904904
//
@@ -911,7 +911,7 @@ protected void RecoverEntities()
911911
RecoverBindings();
912912
}
913913

914-
protected void RecoverExchanges()
914+
private void RecoverExchanges()
915915
{
916916
foreach (RecordedExchange rx in m_recordedExchanges.Values)
917917
{
@@ -928,7 +928,7 @@ protected void RecoverExchanges()
928928
}
929929
}
930930

931-
protected void RecoverModels()
931+
private void RecoverModels()
932932
{
933933
lock (m_models)
934934
{
@@ -939,7 +939,7 @@ protected void RecoverModels()
939939
}
940940
}
941941

942-
protected void RecoverQueues()
942+
private void RecoverQueues()
943943
{
944944
lock (m_recordedQueues)
945945
{
@@ -995,7 +995,7 @@ protected void RecoverQueues()
995995
}
996996
}
997997

998-
protected void RunRecoveryEventHandlers()
998+
private void RunRecoveryEventHandlers()
999999
{
10001000
EventHandler<EventArgs> handler = m_recovery;
10011001
if (handler != null)
@@ -1016,7 +1016,7 @@ protected void RunRecoveryEventHandlers()
10161016
}
10171017
}
10181018

1019-
protected bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
1019+
private bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
10201020
{
10211021
return (args.Initiator == ShutdownInitiator.Peer ||
10221022
// happens when EOF is reached, e.g. due to RabbitMQ node

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
namespace RabbitMQ.Client.Impl
4747
{
48-
public class AutorecoveringModel : IFullModel, IRecoverable
48+
internal sealed class AutorecoveringModel : IFullModel, IRecoverable
4949
{
5050
private readonly object m_eventLock = new object();
5151
private AutorecoveringConnection m_connection;
@@ -319,37 +319,37 @@ public void HandleCommand(ISession session, Command cmd)
319319
m_delegate.HandleCommand(session, cmd);
320320
}
321321

322-
public virtual void OnBasicAck(BasicAckEventArgs args)
322+
public void OnBasicAck(BasicAckEventArgs args)
323323
{
324324
m_delegate.OnBasicAck(args);
325325
}
326326

327-
public virtual void OnBasicNack(BasicNackEventArgs args)
327+
public void OnBasicNack(BasicNackEventArgs args)
328328
{
329329
m_delegate.OnBasicNack(args);
330330
}
331331

332-
public virtual void OnBasicRecoverOk(EventArgs args)
332+
public void OnBasicRecoverOk(EventArgs args)
333333
{
334334
m_delegate.OnBasicRecoverOk(args);
335335
}
336336

337-
public virtual void OnBasicReturn(BasicReturnEventArgs args)
337+
public void OnBasicReturn(BasicReturnEventArgs args)
338338
{
339339
m_delegate.OnBasicReturn(args);
340340
}
341341

342-
public virtual void OnCallbackException(CallbackExceptionEventArgs args)
342+
public void OnCallbackException(CallbackExceptionEventArgs args)
343343
{
344344
m_delegate.OnCallbackException(args);
345345
}
346346

347-
public virtual void OnFlowControl(FlowControlEventArgs args)
347+
public void OnFlowControl(FlowControlEventArgs args)
348348
{
349349
m_delegate.OnFlowControl(args);
350350
}
351351

352-
public virtual void OnModelShutdown(ShutdownEventArgs reason)
352+
public void OnModelShutdown(ShutdownEventArgs reason)
353353
{
354354
m_delegate.OnModelShutdown(reason);
355355
}
@@ -374,7 +374,7 @@ void IDisposable.Dispose()
374374
Dispose(true);
375375
}
376376

377-
protected virtual void Dispose(bool disposing)
377+
private void Dispose(bool disposing)
378378
{
379379
if (disposing)
380380
{

projects/client/RabbitMQ.Client/src/client/impl/ConcurrentConsumerDispatcher.cs

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

55
namespace RabbitMQ.Client.Impl
66
{
7-
internal class ConcurrentConsumerDispatcher : IConsumerDispatcher
7+
internal sealed class ConcurrentConsumerDispatcher : IConsumerDispatcher
88
{
99
private ModelBase model;
1010
private ConsumerWorkService workService;

projects/client/RabbitMQ.Client/src/client/impl/RecordedBinding.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
namespace RabbitMQ.Client.Impl
4545
{
46-
public abstract class RecordedBinding : RecordedEntity
46+
internal abstract class RecordedBinding : RecordedEntity
4747
{
4848
public RecordedBinding(AutorecoveringModel model) : base(model)
4949
{
@@ -124,7 +124,7 @@ public RecordedBinding WithSource(string value)
124124
}
125125

126126

127-
public class RecordedQueueBinding : RecordedBinding
127+
internal sealed class RecordedQueueBinding : RecordedBinding
128128
{
129129
public RecordedQueueBinding(AutorecoveringModel model) : base(model)
130130
{
@@ -137,7 +137,7 @@ public override void Recover()
137137
}
138138

139139

140-
public class RecordedExchangeBinding : RecordedBinding
140+
internal sealed class RecordedExchangeBinding : RecordedBinding
141141
{
142142
public RecordedExchangeBinding(AutorecoveringModel model) : base(model)
143143
{

projects/client/RabbitMQ.Client/src/client/impl/RecordedConsumer.cs

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

4545
namespace RabbitMQ.Client.Impl
4646
{
47-
public class RecordedConsumer : RecordedEntity
47+
internal class RecordedConsumer : RecordedEntity
4848
{
4949
public RecordedConsumer(AutorecoveringModel model, string queue) : base(model)
5050
{

projects/client/RabbitMQ.Client/src/client/impl/RecordedEntity.cs

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

4343
namespace RabbitMQ.Client.Impl
4444
{
45-
public abstract class RecordedEntity
45+
internal abstract class RecordedEntity
4646
{
4747
public RecordedEntity(AutorecoveringModel model)
4848
{

projects/client/RabbitMQ.Client/src/client/impl/RecordedExchange.cs

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

4444
namespace RabbitMQ.Client.Impl
4545
{
46-
public class RecordedExchange : RecordedNamedEntity
46+
internal class RecordedExchange : RecordedNamedEntity
4747
{
4848
private string type;
4949

projects/client/RabbitMQ.Client/src/client/impl/RecordedNamedEntity.cs

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

4343
namespace RabbitMQ.Client.Impl
4444
{
45-
public class RecordedNamedEntity : RecordedEntity
45+
internal class RecordedNamedEntity : RecordedEntity
4646
{
4747
public RecordedNamedEntity(AutorecoveringModel model, string name) : base(model)
4848
{

projects/client/RabbitMQ.Client/src/client/impl/RecordedQueue.cs

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

4444
namespace RabbitMQ.Client.Impl
4545
{
46-
public class RecordedQueue : RecordedNamedEntity
46+
internal class RecordedQueue : RecordedNamedEntity
4747
{
4848
private IDictionary<string, object> arguments;
4949
private bool durable;

0 commit comments

Comments
 (0)