Skip to content

make implementations internal and sealed #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions projects/client/Apigen/src/apigen/Apigen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public void EmitPrelude()
public void EmitPublic()
{
EmitLine("namespace " + ApiNamespaceBase + " {");
EmitLine(" public class Protocol: " + ImplNamespaceBase + ".ProtocolBase {");
EmitLine(" internal sealed class Protocol: " + ImplNamespaceBase + ".ProtocolBase {");
EmitLine(" ///<summary>Protocol major version (= " + m_majorVersion + ")</summary>");
EmitLine(" public override int MajorVersion { get { return " + m_majorVersion + "; } }");
EmitLine(" ///<summary>Protocol minor version (= " + m_minorVersion + ")</summary>");
Expand All @@ -460,7 +460,7 @@ public void EmitPublic()
EmitLine("");
EmitContentHeaderReader();
EmitLine(" }");
EmitLine(" public class Constants {");
EmitLine(" internal sealed class Constants {");
foreach (KeyValuePair<string, int> de in m_constants)
{
EmitLine(" ///<summary>(= " + de.Value + ")</summary>");
Expand Down Expand Up @@ -553,7 +553,7 @@ public void EmitClassProperties(AmqpClass c)
"AMQP specification content header properties for " +
"content class \"" + c.Name + "\"");
EmitSpecComment(c.DocumentationCommentVariant(" ", "remarks"));
EmitLine(" public class " + MangleClass(c.Name)
EmitLine(" internal sealed class " + MangleClass(c.Name)
+ "Properties: " + propertiesBaseClass + " {");
foreach (AmqpField f in c.m_Fields)
{
Expand Down Expand Up @@ -714,7 +714,7 @@ public void EmitClassMethodImplementations(AmqpClass c)
{
EmitAutogeneratedSummary(" ",
"Private implementation class - do not use directly.");
EmitLine(" public class " + MangleMethodClass(c, m)
EmitLine(" internal sealed class " + MangleMethodClass(c, m)
+ ": RabbitMQ.Client.Impl.MethodBase, I" + MangleMethodClass(c, m) + " {");
EmitLine(" public const ushort ClassId = " + c.Index + ";");
EmitLine(" public const ushort MethodId = " + m.Index + ";");
Expand Down Expand Up @@ -898,7 +898,7 @@ public Attribute Attribute(IEnumerable<object> attributes, Type t)

public void EmitModelImplementation()
{
EmitLine(" public class Model: RabbitMQ.Client.Impl.ModelBase {");
EmitLine(" internal class Model: RabbitMQ.Client.Impl.ModelBase {");
EmitLine(" public Model(RabbitMQ.Client.Impl.ISession session): base(session) {}");
EmitLine(" public Model(RabbitMQ.Client.Impl.ISession session, RabbitMQ.Client.ConsumerWorkService workService): base(session, workService) {}");
IList<MethodInfo> asynchronousHandlers = new List<MethodInfo>();
Expand Down
7 changes: 7 additions & 0 deletions projects/client/RabbitMQ.Client/RabbitMQ.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,11 @@
<ItemGroup>
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="4.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Unit</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace RabbitMQ.Client.Impl
{
internal class AsyncConsumerDispatcher : IConsumerDispatcher
internal sealed class AsyncConsumerDispatcher : IConsumerDispatcher
{
private readonly ModelBase model;
private readonly AsyncConsumerWorkService workService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace RabbitMQ.Client
{
internal class AsyncConsumerWorkService : ConsumerWorkService
internal sealed class AsyncConsumerWorkService : ConsumerWorkService
{
readonly ConcurrentDictionary<IModel, WorkPool> workPools = new ConcurrentDictionary<IModel, WorkPool>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@

namespace RabbitMQ.Client.Framing.Impl
{
public class AutorecoveringConnection : IConnection
internal sealed class AutorecoveringConnection : IConnection
{
private readonly object m_eventLock = new object();

private readonly object manuallyClosedLock = new object();
protected Connection m_delegate;
protected ConnectionFactory m_factory;
private Connection m_delegate;
private ConnectionFactory m_factory;

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

Expand Down Expand Up @@ -387,7 +387,7 @@ public void BeginAutomaticRecovery()
}
}

protected void PerformAutomaticRecovery()
private void PerformAutomaticRecovery()
{
ESLog.Info("Performing automatic recovery");
lock (recoveryLockTarget)
Expand Down Expand Up @@ -715,7 +715,7 @@ void IDisposable.Dispose()
Dispose(true);
}

protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing)
{
Expand All @@ -740,17 +740,17 @@ protected virtual void Dispose(bool disposing)
// dispose unmanaged resources
}

protected void EnsureIsOpen()
private void EnsureIsOpen()
{
m_delegate.EnsureIsOpen();
}

protected void HandleTopologyRecoveryException(TopologyRecoveryException e)
private void HandleTopologyRecoveryException(TopologyRecoveryException e)
{
ESLog.Error("Topology recovery exception", e);
}

protected void PropagateQueueNameChangeToBindings(string oldName, string newName)
private void PropagateQueueNameChangeToBindings(string oldName, string newName)
{
lock (m_recordedBindings)
{
Expand All @@ -762,7 +762,7 @@ protected void PropagateQueueNameChangeToBindings(string oldName, string newName
}
}

protected void PropagateQueueNameChangeToConsumers(string oldName, string newName)
private void PropagateQueueNameChangeToConsumers(string oldName, string newName)
{
lock (m_recordedBindings)
{
Expand All @@ -775,7 +775,7 @@ protected void PropagateQueueNameChangeToConsumers(string oldName, string newNam
}
}

protected void RecoverBindings()
private void RecoverBindings()
{
foreach (var b in m_recordedBindings.Keys)
{
Expand All @@ -792,15 +792,15 @@ protected void RecoverBindings()
}
}

protected void RecoverConnectionBlockedHandlers()
private void RecoverConnectionBlockedHandlers()
{
lock (m_eventLock)
{
m_delegate.ConnectionBlocked += m_recordedBlockedEventHandlers;
}
}

protected bool RecoverConnectionDelegate()
private bool RecoverConnectionDelegate()
{
while (!ManuallyClosed)
{
Expand Down Expand Up @@ -844,17 +844,17 @@ protected bool RecoverConnectionDelegate()
return false;
}

protected void RecoverConnectionShutdownHandlers()
private void RecoverConnectionShutdownHandlers()
{
m_delegate.ConnectionShutdown += m_recordedShutdownEventHandlers;
}

protected void RecoverConnectionUnblockedHandlers()
private void RecoverConnectionUnblockedHandlers()
{
m_delegate.ConnectionUnblocked += m_recordedUnblockedEventHandlers;
}

protected void RecoverConsumers()
private void RecoverConsumers()
{
foreach (KeyValuePair<string, RecordedConsumer> pair in m_recordedConsumers)
{
Expand Down Expand Up @@ -898,7 +898,7 @@ protected void RecoverConsumers()
}
}

protected void RecoverEntities()
private void RecoverEntities()
{
// The recovery sequence is the following:
//
Expand All @@ -911,7 +911,7 @@ protected void RecoverEntities()
RecoverBindings();
}

protected void RecoverExchanges()
private void RecoverExchanges()
{
foreach (RecordedExchange rx in m_recordedExchanges.Values)
{
Expand All @@ -928,7 +928,7 @@ protected void RecoverExchanges()
}
}

protected void RecoverModels()
private void RecoverModels()
{
lock (m_models)
{
Expand All @@ -939,7 +939,7 @@ protected void RecoverModels()
}
}

protected void RecoverQueues()
private void RecoverQueues()
{
lock (m_recordedQueues)
{
Expand Down Expand Up @@ -995,7 +995,7 @@ protected void RecoverQueues()
}
}

protected void RunRecoveryEventHandlers()
private void RunRecoveryEventHandlers()
{
EventHandler<EventArgs> handler = m_recovery;
if (handler != null)
Expand All @@ -1016,7 +1016,7 @@ protected void RunRecoveryEventHandlers()
}
}

protected bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
private bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
{
return (args.Initiator == ShutdownInitiator.Peer ||
// happens when EOF is reached, e.g. due to RabbitMQ node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

namespace RabbitMQ.Client.Impl
{
public class AutorecoveringModel : IFullModel, IRecoverable
internal sealed class AutorecoveringModel : IFullModel, IRecoverable
{
private readonly object m_eventLock = new object();
private AutorecoveringConnection m_connection;
Expand Down Expand Up @@ -319,37 +319,37 @@ public void HandleCommand(ISession session, Command cmd)
m_delegate.HandleCommand(session, cmd);
}

public virtual void OnBasicAck(BasicAckEventArgs args)
public void OnBasicAck(BasicAckEventArgs args)
{
m_delegate.OnBasicAck(args);
}

public virtual void OnBasicNack(BasicNackEventArgs args)
public void OnBasicNack(BasicNackEventArgs args)
{
m_delegate.OnBasicNack(args);
}

public virtual void OnBasicRecoverOk(EventArgs args)
public void OnBasicRecoverOk(EventArgs args)
{
m_delegate.OnBasicRecoverOk(args);
}

public virtual void OnBasicReturn(BasicReturnEventArgs args)
public void OnBasicReturn(BasicReturnEventArgs args)
{
m_delegate.OnBasicReturn(args);
}

public virtual void OnCallbackException(CallbackExceptionEventArgs args)
public void OnCallbackException(CallbackExceptionEventArgs args)
{
m_delegate.OnCallbackException(args);
}

public virtual void OnFlowControl(FlowControlEventArgs args)
public void OnFlowControl(FlowControlEventArgs args)
{
m_delegate.OnFlowControl(args);
}

public virtual void OnModelShutdown(ShutdownEventArgs reason)
public void OnModelShutdown(ShutdownEventArgs reason)
{
m_delegate.OnModelShutdown(reason);
}
Expand All @@ -374,7 +374,7 @@ void IDisposable.Dispose()
Dispose(true);
}

protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace RabbitMQ.Client.Impl
{
internal class ConcurrentConsumerDispatcher : IConsumerDispatcher
internal sealed class ConcurrentConsumerDispatcher : IConsumerDispatcher
{
private ModelBase model;
private ConsumerWorkService workService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

namespace RabbitMQ.Client.Impl
{
public abstract class RecordedBinding : RecordedEntity
internal abstract class RecordedBinding : RecordedEntity
{
public RecordedBinding(AutorecoveringModel model) : base(model)
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public RecordedBinding WithSource(string value)
}


public class RecordedQueueBinding : RecordedBinding
internal sealed class RecordedQueueBinding : RecordedBinding
{
public RecordedQueueBinding(AutorecoveringModel model) : base(model)
{
Expand All @@ -137,7 +137,7 @@ public override void Recover()
}


public class RecordedExchangeBinding : RecordedBinding
internal sealed class RecordedExchangeBinding : RecordedBinding
{
public RecordedExchangeBinding(AutorecoveringModel model) : base(model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

namespace RabbitMQ.Client.Impl
{
public class RecordedConsumer : RecordedEntity
internal class RecordedConsumer : RecordedEntity
{
public RecordedConsumer(AutorecoveringModel model, string queue) : base(model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

namespace RabbitMQ.Client.Impl
{
public abstract class RecordedEntity
internal abstract class RecordedEntity
{
public RecordedEntity(AutorecoveringModel model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

namespace RabbitMQ.Client.Impl
{
public class RecordedExchange : RecordedNamedEntity
internal class RecordedExchange : RecordedNamedEntity
{
private string type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

namespace RabbitMQ.Client.Impl
{
public class RecordedNamedEntity : RecordedEntity
internal class RecordedNamedEntity : RecordedEntity
{
public RecordedNamedEntity(AutorecoveringModel model, string name) : base(model)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

namespace RabbitMQ.Client.Impl
{
public class RecordedQueue : RecordedNamedEntity
internal class RecordedQueue : RecordedNamedEntity
{
private IDictionary<string, object> arguments;
private bool durable;
Expand Down
Loading