Skip to content
5 changes: 5 additions & 0 deletions sdk/storage/Azure.Storage.Queues/BreakingChanges.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Breaking Changes
================

12.24.0-beta.1 (Unreleased)
---------------------------
- 'QueueProperties.ApproximateMessagesCount' will now throw an OverflowException if the value exceeds int.MaxValue.
Please use 'QueueProperties.ApproximateMessagesCountLong' instead.

12.0.0 (2019-11)
--------------------------
- Renamed a number of operations and models to better align with other client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ public QueueMetrics() { }
public partial class QueueProperties
{
public QueueProperties() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public int ApproximateMessagesCount { get { throw null; } }
public long ApproximateMessagesCountLong { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
}
public partial class QueueRetentionPolicy
Expand Down Expand Up @@ -388,7 +390,9 @@ public static partial class QueuesModelFactory
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, System.BinaryData body, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, string messageText, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, int approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, long approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueServiceStatistics QueueServiceStatistics(Azure.Storage.Queues.Models.QueueGeoReplication geoReplication = null) { throw null; }
public static Azure.Storage.Queues.Models.SendReceipt SendReceipt(string messageId, System.DateTimeOffset insertionTime, System.DateTimeOffset expirationTime, string popReceipt, System.DateTimeOffset timeNextVisible) { throw null; }
public static Azure.Storage.Queues.Models.UpdateReceipt UpdateReceipt(string popReceipt, System.DateTimeOffset nextVisibleOn) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ public QueueMetrics() { }
public partial class QueueProperties
{
public QueueProperties() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public int ApproximateMessagesCount { get { throw null; } }
public long ApproximateMessagesCountLong { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
}
public partial class QueueRetentionPolicy
Expand Down Expand Up @@ -388,7 +390,9 @@ public static partial class QueuesModelFactory
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, System.BinaryData body, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, string messageText, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, int approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, long approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueServiceStatistics QueueServiceStatistics(Azure.Storage.Queues.Models.QueueGeoReplication geoReplication = null) { throw null; }
public static Azure.Storage.Queues.Models.SendReceipt SendReceipt(string messageId, System.DateTimeOffset insertionTime, System.DateTimeOffset expirationTime, string popReceipt, System.DateTimeOffset timeNextVisible) { throw null; }
public static Azure.Storage.Queues.Models.UpdateReceipt UpdateReceipt(string popReceipt, System.DateTimeOffset nextVisibleOn) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ public QueueMetrics() { }
public partial class QueueProperties
{
public QueueProperties() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public int ApproximateMessagesCount { get { throw null; } }
public long ApproximateMessagesCountLong { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
}
public partial class QueueRetentionPolicy
Expand Down Expand Up @@ -388,7 +390,9 @@ public static partial class QueuesModelFactory
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, System.BinaryData body, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, string messageText, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, int approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, long approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueServiceStatistics QueueServiceStatistics(Azure.Storage.Queues.Models.QueueGeoReplication geoReplication = null) { throw null; }
public static Azure.Storage.Queues.Models.SendReceipt SendReceipt(string messageId, System.DateTimeOffset insertionTime, System.DateTimeOffset expirationTime, string popReceipt, System.DateTimeOffset timeNextVisible) { throw null; }
public static Azure.Storage.Queues.Models.UpdateReceipt UpdateReceipt(string popReceipt, System.DateTimeOffset nextVisibleOn) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ public QueueMetrics() { }
public partial class QueueProperties
{
public QueueProperties() { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public int ApproximateMessagesCount { get { throw null; } }
public long ApproximateMessagesCountLong { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
}
public partial class QueueRetentionPolicy
Expand Down Expand Up @@ -388,7 +390,9 @@ public static partial class QueuesModelFactory
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, System.BinaryData body, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueMessage QueueMessage(string messageId, string popReceipt, string messageText, long dequeueCount, System.DateTimeOffset? nextVisibleOn = default(System.DateTimeOffset?), System.DateTimeOffset? insertedOn = default(System.DateTimeOffset?), System.DateTimeOffset? expiresOn = default(System.DateTimeOffset?)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, int approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueProperties QueueProperties(System.Collections.Generic.IDictionary<string, string> metadata, long approximateMessagesCount) { throw null; }
public static Azure.Storage.Queues.Models.QueueServiceStatistics QueueServiceStatistics(Azure.Storage.Queues.Models.QueueGeoReplication geoReplication = null) { throw null; }
public static Azure.Storage.Queues.Models.SendReceipt SendReceipt(string messageId, System.DateTimeOffset insertionTime, System.DateTimeOffset expirationTime, string popReceipt, System.DateTimeOffset timeNextVisible) { throw null; }
public static Azure.Storage.Queues.Models.UpdateReceipt UpdateReceipt(string popReceipt, System.DateTimeOffset nextVisibleOn) { throw null; }
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Queues/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/storage/Azure.Storage.Queues",
"Tag": "net/storage/Azure.Storage.Queues_95435e3a7a"
"Tag": "net/storage/Azure.Storage.Queues_975e82f8f8"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion sdk/storage/Azure.Storage.Queues/src/Models/QueueProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System.Collections.Generic;
using System.ComponentModel;

namespace Azure.Storage.Queues.Models
{
Expand All @@ -18,7 +19,17 @@ public class QueueProperties
/// <summary>
/// The approximate number of messages in the queue. This number is not lower than the actual number of messages in the queue, but could be higher.
/// </summary>
public int ApproximateMessagesCount { get; internal set; }
[EditorBrowsable(EditorBrowsableState.Never)]
public int ApproximateMessagesCount
{
get => checked((int)ApproximateMessagesCountLong);
Comment thread
nickliu-msft marked this conversation as resolved.
Outdated
internal set => ApproximateMessagesCountLong = value;
}

/// <summary>
/// The approximate number of messages in the queue. This number is not lower than the actual number of messages in the queue, but could be higher.
/// </summary>
public long ApproximateMessagesCountLong { get; internal set; }

/// <summary>
/// Creates a new QueueProperties instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static QueueItem QueueItem(
/// <summary>
/// Creates a new QueueProperties instance for mocking.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static QueueProperties QueueProperties(
IDictionary<string, string> metadata,
int approximateMessagesCount)
Expand All @@ -132,6 +133,20 @@ public static QueueProperties QueueProperties(
};
}

/// <summary>
/// Creates a new QueueProperties instance for mocking.
/// </summary>
public static QueueProperties QueueProperties(
IDictionary<string, string> metadata,
long approximateMessagesCount)
{
return new QueueProperties()
{
Metadata = metadata,
ApproximateMessagesCountLong = approximateMessagesCount,
};
}

/// <summary>
/// Creates a new QueueServiceStatistics instance for mocking.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Queues/src/QueueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ private async Task<Response<QueueProperties>> GetPropertiesInternal(

QueueProperties queueProperties = new QueueProperties
{
ApproximateMessagesCount = response.Headers.ApproximateMessagesCount.GetValueOrDefault(),
ApproximateMessagesCountLong = response.Headers.ApproximateMessagesCount.GetValueOrDefault(),
Metadata = response.Headers.Metadata
};

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Queues/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Run `dotnet build /t:GenerateCode` to generate code.

``` yaml
input-file:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/5da3c08b92d05858b728b013b69502dc93485373/specification/storage/data-plane/Microsoft.QueueStorage/stable/2018-03-28/queue.json
- https://raw.githubusercontent.com/nickliu-msft/azure-rest-api-specs/99002620b34fb38a15571130dd4c780a455785eb/specification/storage/data-plane/Microsoft.QueueStorage/stable/2018-03-28/queue.json
Comment thread
nickliu-msft marked this conversation as resolved.
Outdated
generation1-convenience-client: true
# https://github.com/Azure/autorest/issues/4075
skip-semantics-validation: true
Expand Down
49 changes: 49 additions & 0 deletions sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Moq.Protected;
using Azure.Core.TestFramework;
using Azure.Identity;
using System.Threading;

namespace Azure.Storage.Queues.Test
{
Expand Down Expand Up @@ -638,6 +639,54 @@ public async Task GetPropertiesAsync()
Assert.IsNotNull(queueProperties);
}

[TestCase(0)]
[TestCase(5)]
[TestCase(12)]
[RecordedTest]
public async Task GetPropertiesAsync_ApproximateMessagesCountLong(int messageCount)
{
// Arrange
await using DisposingQueue test = await GetTestQueueAsync();

// Act
for (int i = 0; i < messageCount; i++)
{
await test.Queue.SendMessageAsync($"Message {i + 1}");
}

Response<Models.QueueProperties> queueProperties = await test.Queue.GetPropertiesAsync();

// Assert
Assert.IsNotNull(queueProperties);
Assert.AreEqual(messageCount, queueProperties.Value.ApproximateMessagesCount);
Assert.AreEqual(messageCount, queueProperties.Value.ApproximateMessagesCountLong);
}

[RecordedTest]
public async Task GetPropertiesAsync_ApproximateMessagesCountOverflow()
{
// Arrange
var mockQueue = new Mock<QueueClient>();
var mockResponse = new Mock<Response<Models.QueueProperties>>();

long msgCount = long.MaxValue;
var queueProperties = new Models.QueueProperties()
{
ApproximateMessagesCountLong = msgCount
};

mockResponse.Setup(r => r.Value).Returns(queueProperties);
mockQueue.Setup(q => q.GetPropertiesAsync(It.IsAny<CancellationToken>())).ReturnsAsync(mockResponse.Object);

// Act
var result = await mockQueue.Object.GetPropertiesAsync();

// Assert
Assert.NotNull(result);
Assert.AreEqual(msgCount, result.Value.ApproximateMessagesCountLong);
Assert.Throws<OverflowException>(() => _ = result.Value.ApproximateMessagesCount);
}

[RecordedTest]
public async Task GetPropertiesAsync_Error()
{
Expand Down
Loading