Skip to content

Commit af8c072

Browse files
committed
use ref Properties in interface
1 parent 0210ac9 commit af8c072

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ string BasicConsume(
188188
/// Routing key must be shorter than 255 bytes.
189189
/// </para>
190190
/// </remarks>
191-
void BasicPublish<TProperties>(string exchange, string routingKey, in TProperties basicProperties, ReadOnlyMemory<byte> body = default, bool mandatory = false)
191+
void BasicPublish<TProperties>(string exchange, string routingKey, ref TProperties basicProperties, ReadOnlyMemory<byte> body = default, bool mandatory = false)
192192
where TProperties : IReadOnlyBasicProperties, IAmqpHeader;
193193
/// <summary>
194194
/// Publishes a message.
@@ -198,7 +198,7 @@ void BasicPublish<TProperties>(string exchange, string routingKey, in TPropertie
198198
/// Routing key must be shorter than 255 bytes.
199199
/// </para>
200200
/// </remarks>
201-
void BasicPublish<TProperties>(CachedString exchange, CachedString routingKey, in TProperties basicProperties, ReadOnlyMemory<byte> body = default, bool mandatory = false)
201+
void BasicPublish<TProperties>(CachedString exchange, CachedString routingKey, ref TProperties basicProperties, ReadOnlyMemory<byte> body = default, bool mandatory = false)
202202
where TProperties : IReadOnlyBasicProperties, IAmqpHeader;
203203
#nullable disable
204204

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ public static string BasicConsume(this IModel model, string queue,
8282
/// <remarks>
8383
/// The publication occurs with mandatory=false and immediate=false.
8484
/// </remarks>
85-
public static void BasicPublish<T>(this IModel model, PublicationAddress addr, in T basicProperties, ReadOnlyMemory<byte> body)
85+
public static void BasicPublish<T>(this IModel model, PublicationAddress addr, ref T basicProperties, ReadOnlyMemory<byte> body)
8686
where T : IReadOnlyBasicProperties, IAmqpHeader
8787
{
88-
model.BasicPublish(addr.ExchangeName, addr.RoutingKey, basicProperties, body);
88+
model.BasicPublish(addr.ExchangeName, addr.RoutingKey, ref basicProperties, body);
8989
}
9090

9191
public static void BasicPublish(this IModel model, string exchange, string routingKey, ReadOnlyMemory<byte> body = default, bool mandatory = false)
92-
=> model.BasicPublish(exchange, routingKey, default(EmptyBasicProperty), body, mandatory);
92+
=> model.BasicPublish(exchange, routingKey, ref EmptyBasicProperty.Empty, body, mandatory);
9393

9494
public static void BasicPublish(this IModel model, CachedString exchange, CachedString routingKey, ReadOnlyMemory<byte> body = default, bool mandatory = false)
95-
=> model.BasicPublish(exchange, routingKey, default(EmptyBasicProperty), body, mandatory);
95+
=> model.BasicPublish(exchange, routingKey, ref EmptyBasicProperty.Empty, body, mandatory);
9696
#nullable disable
9797

9898
/// <summary>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ public BasicGetResult BasicGet(string queue, bool autoAck)
242242
public void BasicNack(ulong deliveryTag, bool multiple, bool requeue)
243243
=> InnerChannel.BasicNack(deliveryTag, multiple, requeue);
244244

245-
public void BasicPublish<TProperties>(string exchange, string routingKey, in TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
245+
public void BasicPublish<TProperties>(string exchange, string routingKey, ref TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
246246
where TProperties : IReadOnlyBasicProperties, IAmqpHeader
247-
=> InnerChannel.BasicPublish(exchange, routingKey, basicProperties, body, mandatory);
247+
=> InnerChannel.BasicPublish(exchange, routingKey, ref basicProperties, body, mandatory);
248248

249-
public void BasicPublish<TProperties>(CachedString exchange, CachedString routingKey, in TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
249+
public void BasicPublish<TProperties>(CachedString exchange, CachedString routingKey, ref TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
250250
where TProperties : IReadOnlyBasicProperties, IAmqpHeader
251-
=> InnerChannel.BasicPublish(exchange, routingKey, basicProperties, body, mandatory);
251+
=> InnerChannel.BasicPublish(exchange, routingKey, ref basicProperties, body, mandatory);
252252

253253
public void BasicQos(uint prefetchSize, ushort prefetchCount, bool global)
254254
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace RabbitMQ.Client.client.impl
88
#nullable enable
99
internal readonly struct EmptyBasicProperty : IReadOnlyBasicProperties, IAmqpHeader
1010
{
11+
internal static EmptyBasicProperty Empty;
12+
1113
ushort IAmqpHeader.ProtocolClassId => ClassConstants.Basic;
1214

1315
int IAmqpWriteable.WriteTo(Span<byte> span)

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ public BasicGetResult BasicGet(string queue, bool autoAck)
897897

898898
public abstract void BasicNack(ulong deliveryTag, bool multiple, bool requeue);
899899

900-
public void BasicPublish<TProperties>(string exchange, string routingKey, in TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
900+
public void BasicPublish<TProperties>(string exchange, string routingKey, ref TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
901901
where TProperties : IReadOnlyBasicProperties, IAmqpHeader
902902
{
903903
if (NextPublishSeqNo > 0)
@@ -909,11 +909,10 @@ public void BasicPublish<TProperties>(string exchange, string routingKey, in TPr
909909
}
910910

911911
var cmd = new BasicPublish(exchange, routingKey, mandatory, default);
912-
var props = basicProperties;
913-
ModelSend(ref cmd, ref props, body);
912+
ModelSend(ref cmd, ref basicProperties, body);
914913
}
915914

916-
public void BasicPublish<TProperties>(CachedString exchange, CachedString routingKey, in TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
915+
public void BasicPublish<TProperties>(CachedString exchange, CachedString routingKey, ref TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory)
917916
where TProperties : IReadOnlyBasicProperties, IAmqpHeader
918917
{
919918
if (NextPublishSeqNo > 0)
@@ -925,8 +924,7 @@ public void BasicPublish<TProperties>(CachedString exchange, CachedString routin
925924
}
926925

927926
var cmd = new BasicPublishMemory(exchange.Bytes, routingKey.Bytes, mandatory, default);
928-
var props = basicProperties;
929-
ModelSend(ref cmd, ref props, body);
927+
ModelSend(ref cmd, ref basicProperties, body);
930928
}
931929

932930
public void UpdateSecret(string newSecret, string reason)

projects/TestApplications/MassPublish/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void Main()
4848
{
4949
AppId = "testapp",
5050
};
51-
publisher.BasicPublish("test", "myawesome.routing.key", properties, payload);
51+
publisher.BasicPublish("test", "myawesome.routing.key", ref properties, payload);
5252
}
5353
messagesSent += ItemsPerBatch;
5454
await publisher.WaitForConfirmsOrDieAsync().ConfigureAwait(false);

projects/Unit/TestBasicPublish.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void TestBasicRoundtripArray()
3232
};
3333
string tag = m.BasicConsume(q.QueueName, true, consumer);
3434

35-
m.BasicPublish("", q.QueueName, bp, sendBody);
35+
m.BasicPublish("", q.QueueName, ref bp, sendBody);
3636
bool waitResFalse = are.WaitOne(2000);
3737
m.BasicCancel(tag);
3838

projects/Unit/TestConnectionRecovery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ public void TestPublishRpcRightAfterReconnect()
817817
{
818818
try
819819
{
820-
_model.BasicPublish(string.Empty, testQueueName, properties, ReadOnlyMemory<byte>.Empty);
820+
_model.BasicPublish(string.Empty, testQueueName, ref properties, ReadOnlyMemory<byte>.Empty);
821821
}
822822
catch (Exception e)
823823
{

0 commit comments

Comments
 (0)