Skip to content

Commit 3188515

Browse files
authored
Merge pull request #1609 from rabbitmq/rabbitmq-dotnet-client-1607-followup
Make `BasicProperties` a class
2 parents 7781e4e + cc1a969 commit 3188515

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

projects/RabbitMQ.Client/PublicAPI.Shipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ RabbitMQ.Client.BasicProperties
122122
RabbitMQ.Client.BasicProperties.AppId.get -> string
123123
RabbitMQ.Client.BasicProperties.AppId.set -> void
124124
RabbitMQ.Client.BasicProperties.BasicProperties() -> void
125-
RabbitMQ.Client.BasicProperties.BasicProperties(in RabbitMQ.Client.ReadOnlyBasicProperties input) -> void
125+
RabbitMQ.Client.BasicProperties.BasicProperties(RabbitMQ.Client.ReadOnlyBasicProperties input) -> void
126126
RabbitMQ.Client.BasicProperties.ClearAppId() -> void
127127
RabbitMQ.Client.BasicProperties.ClearClusterId() -> void
128128
RabbitMQ.Client.BasicProperties.ClearContentEncoding() -> void
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RabbitMQ.Client.BasicProperties.BasicProperties(RabbitMQ.Client.ReadOnlyBasicProperties! input) -> void

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace RabbitMQ.Client
4040
/// <summary>
4141
/// AMQP specification content header properties for content class "basic".
4242
/// </summary>
43-
public struct BasicProperties : IBasicProperties, IAmqpHeader
43+
public sealed class BasicProperties : IBasicProperties, IAmqpHeader
4444
{
4545
public string? ContentType { get; set; }
4646
public string? ContentEncoding { get; set; }
@@ -59,7 +59,7 @@ public struct BasicProperties : IBasicProperties, IAmqpHeader
5959

6060
public bool Persistent
6161
{
62-
readonly get
62+
get
6363
{
6464
return DeliveryMode == DeliveryModes.Persistent;
6565
}
@@ -72,7 +72,7 @@ readonly get
7272

7373
public PublicationAddress? ReplyToAddress
7474
{
75-
readonly get
75+
get
7676
{
7777
PublicationAddress.TryParse(ReplyTo, out PublicationAddress result);
7878
return result;
@@ -81,7 +81,11 @@ readonly get
8181
set { ReplyTo = value?.ToString(); }
8282
}
8383

84-
public BasicProperties(in ReadOnlyBasicProperties input)
84+
public BasicProperties()
85+
{
86+
}
87+
88+
public BasicProperties(ReadOnlyBasicProperties input)
8589
{
8690
ContentType = input.ContentType;
8791
ContentEncoding = input.ContentEncoding;
@@ -114,20 +118,20 @@ public BasicProperties(in ReadOnlyBasicProperties input)
114118
public void ClearAppId() => AppId = default;
115119
public void ClearClusterId() => ClusterId = default;
116120

117-
public readonly bool IsContentTypePresent() => ContentType != default;
118-
public readonly bool IsContentEncodingPresent() => ContentEncoding != default;
119-
public readonly bool IsHeadersPresent() => Headers != default;
120-
public readonly bool IsDeliveryModePresent() => DeliveryMode != default;
121-
public readonly bool IsPriorityPresent() => Priority != default;
122-
public readonly bool IsCorrelationIdPresent() => CorrelationId != default;
123-
public readonly bool IsReplyToPresent() => ReplyTo != default;
124-
public readonly bool IsExpirationPresent() => Expiration != default;
125-
public readonly bool IsMessageIdPresent() => MessageId != default;
126-
public readonly bool IsTimestampPresent() => Timestamp != default;
127-
public readonly bool IsTypePresent() => Type != default;
128-
public readonly bool IsUserIdPresent() => UserId != default;
129-
public readonly bool IsAppIdPresent() => AppId != default;
130-
public readonly bool IsClusterIdPresent() => ClusterId != default;
121+
public bool IsContentTypePresent() => ContentType != default;
122+
public bool IsContentEncodingPresent() => ContentEncoding != default;
123+
public bool IsHeadersPresent() => Headers != default;
124+
public bool IsDeliveryModePresent() => DeliveryMode != default;
125+
public bool IsPriorityPresent() => Priority != default;
126+
public bool IsCorrelationIdPresent() => CorrelationId != default;
127+
public bool IsReplyToPresent() => ReplyTo != default;
128+
public bool IsExpirationPresent() => Expiration != default;
129+
public bool IsMessageIdPresent() => MessageId != default;
130+
public bool IsTimestampPresent() => Timestamp != default;
131+
public bool IsTypePresent() => Type != default;
132+
public bool IsUserIdPresent() => UserId != default;
133+
public bool IsAppIdPresent() => AppId != default;
134+
public bool IsClusterIdPresent() => ClusterId != default;
131135

132136
ushort IAmqpHeader.ProtocolClassId => ClassConstants.Basic;
133137

@@ -153,7 +157,7 @@ public BasicProperties(in ReadOnlyBasicProperties input)
153157
internal const byte AppIdBit = 3;
154158
internal const byte ClusterIdBit = 2;
155159

156-
readonly int IAmqpWriteable.WriteTo(Span<byte> span)
160+
int IAmqpWriteable.WriteTo(Span<byte> span)
157161
{
158162
int offset = 2;
159163
ref byte bitValue = ref span.GetStart();
@@ -247,7 +251,7 @@ readonly int IAmqpWriteable.WriteTo(Span<byte> span)
247251
return offset;
248252
}
249253

250-
readonly int IAmqpWriteable.GetRequiredBufferSize()
254+
int IAmqpWriteable.GetRequiredBufferSize()
251255
{
252256
int bufferSize = 2; // number of presence fields (14) in 2 bytes blocks
253257
if (IsContentTypePresent()) { bufferSize += 1 + WireFormatting.GetByteCount(ContentType); } // _contentType in bytes

0 commit comments

Comments
 (0)