Skip to content

Commit a488b73

Browse files
bieluclaude
andcommitted
fix: mark MQTT int accessors that hide large and schema values as obsolete
MQTTServerBinding.SessionExpiryInterval, MaximumPacketSize and MQTTOperationBinding.MessageExpiryInterval are int? views over the MQTTIntegerOrSchema values. They return null when the value is a schema or above Int32.MaxValue, which MQTT allows (up to 4294967295; for the session expiry interval 0xFFFFFFFF means "never expires"). Callers cannot tell that apart from "not set". Keep the properties for compatibility, but document the behaviour and mark them [Obsolete] pointing to the *Value properties. Tests now use the *Value properties. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 70e73db commit a488b73

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎src/ByteBard.AsyncAPI.Bindings/MQTT/MQTTOperationBinding.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public bool Retain
3535
/// <summary>
3636
/// Interval in seconds or a Schema Object containing the definition of the lifetime of the message.
3737
/// </summary>
38+
/// <remarks>
39+
/// Returns null when the value is a schema or does not fit in an Int32 (MQTT allows up to 4294967295).
40+
/// Use <see cref="MessageExpiryIntervalValue"/> to read every value.
41+
/// </remarks>
42+
[Obsolete("Returns null for schema values and values above Int32.MaxValue. Use MessageExpiryIntervalValue instead.")]
3843
public int? MessageExpiryInterval
3944
{
4045
get => this.MessageExpiryIntervalValue?.Integer;

‎src/ByteBard.AsyncAPI.Bindings/MQTT/MQTTServerBinding.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public class MQTTServerBinding : ServerBinding<MQTTServerBinding>
3737
/// Interval in seconds the broker maintains a session
3838
/// for a disconnected client until this interval expires.
3939
/// </summary>
40+
/// <remarks>
41+
/// Returns null when the value is a schema or does not fit in an Int32 (MQTT allows up to 4294967295).
42+
/// Use <see cref="SessionExpiryIntervalValue"/> to read every value.
43+
/// </remarks>
44+
[Obsolete("Returns null for schema values and values above Int32.MaxValue. Use SessionExpiryIntervalValue instead.")]
4045
public int? SessionExpiryInterval
4146
{
4247
get => this.SessionExpiryIntervalValue?.Integer;
@@ -50,6 +55,11 @@ public int? SessionExpiryInterval
5055
/// Number of bytes representing the maximum packet size
5156
/// the client is willing to accept.
5257
/// </summary>
58+
/// <remarks>
59+
/// Returns null when the value is a schema or does not fit in an Int32 (MQTT allows up to 4294967295).
60+
/// Use <see cref="MaximumPacketSizeValue"/> to read every value.
61+
/// </remarks>
62+
[Obsolete("Returns null for schema values and values above Int32.MaxValue. Use MaximumPacketSizeValue instead.")]
5363
public int? MaximumPacketSize
5464
{
5565
get => this.MaximumPacketSizeValue?.Integer;

‎test/ByteBard.AsyncAPI.Tests/Bindings/BindingExtensions_Should.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void V2_TryGetValue_WithOperationBinding_ReturnsBinding()
5555
operation.Bindings.Add(new MQTTOperationBinding
5656
{
5757
QoS = 23,
58-
MessageExpiryInterval = 1,
58+
MessageExpiryIntervalValue = MQTTIntegerOrSchema.FromInteger(1),
5959
Retain = true,
6060
});
6161

‎test/ByteBard.AsyncAPI.Tests/MQTT/MQTTBindings_Should.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public void V2_MQTTServerBinding_FilledObject_SerializesAndDeserializes()
4646
Retain = false,
4747
},
4848
KeepAlive = 60,
49-
SessionExpiryInterval = 600,
50-
MaximumPacketSize = 1200,
49+
SessionExpiryIntervalValue = MQTTIntegerOrSchema.FromInteger(600),
50+
MaximumPacketSizeValue = MQTTIntegerOrSchema.FromInteger(1200),
5151
});
5252

5353
// Act
@@ -82,7 +82,7 @@ public void V2_MQTTOperationBinding_WithFilledObject_SerializesAndDeserializes()
8282
{
8383
QoS = 2,
8484
Retain = true,
85-
MessageExpiryInterval = 60,
85+
MessageExpiryIntervalValue = MQTTIntegerOrSchema.FromInteger(60),
8686
});
8787

8888
// Act

0 commit comments

Comments
 (0)