Skip to content
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

[Storage] API feedback - Change IEnumerable<T> to T[] #7750

Merged
merged 1 commit into from
Sep 25, 2019
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
30 changes: 16 additions & 14 deletions sdk/storage/Azure.Storage.Queues/src/QueueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,9 @@ await QueueRestClient.Messages.EnqueueAsync(
/// Optional <see cref="CancellationToken"/>
/// </param>
/// <returns>
/// <see cref="Response{T}"/> of <see cref="IEnumerable{DequeuedMessage}"/>
/// <see cref="Response{T}"/> where T is an array of <see cref="DequeuedMessage"/>
/// </returns>
public virtual Response<IEnumerable<DequeuedMessage>> DequeueMessages(
public virtual Response<DequeuedMessage[]> DequeueMessages(
int? maxMessages = default,
TimeSpan? visibilityTimeout = default,
CancellationToken cancellationToken = default) =>
Expand All @@ -1015,9 +1015,9 @@ public virtual Response<IEnumerable<DequeuedMessage>> DequeueMessages(
/// Optional <see cref="CancellationToken"/>
/// </param>
/// <returns>
/// <see cref="Response{T}"/> of <see cref="IEnumerable{DequeuedMessage}"/>
/// <see cref="Response{T}"/> where T is an array of <see cref="DequeuedMessage"/>
/// </returns>
public virtual async Task<Response<IEnumerable<DequeuedMessage>>> DequeueMessagesAsync(
public virtual async Task<Response<DequeuedMessage[]>> DequeueMessagesAsync(
int? maxMessages = default,
TimeSpan? visibilityTimeout = default,
CancellationToken cancellationToken = default) =>
Expand Down Expand Up @@ -1046,9 +1046,9 @@ await DequeueMessagesInternal(
/// Optional <see cref="CancellationToken"/>
/// </param>
/// <returns>
/// <see cref="Response{T}"/> of <see cref="IEnumerable{DequeuedMessage}"/>
/// <see cref="Response{T}"/> where T is an array of <see cref="DequeuedMessage"/>
/// </returns>
private async Task<Response<IEnumerable<DequeuedMessage>>> DequeueMessagesInternal(
private async Task<Response<DequeuedMessage[]>> DequeueMessagesInternal(
int? maxMessages,
TimeSpan? visibilityTimeout,
bool async,
Expand All @@ -1064,7 +1064,7 @@ private async Task<Response<IEnumerable<DequeuedMessage>>> DequeueMessagesIntern
$"{nameof(visibilityTimeout)}: {visibilityTimeout}");
try
{
return await QueueRestClient.Messages.DequeueAsync(
var dequeuedMessage = await QueueRestClient.Messages.DequeueAsync(
Pipeline,
MessagesUri,
numberOfMessages: maxMessages,
Expand All @@ -1073,6 +1073,7 @@ private async Task<Response<IEnumerable<DequeuedMessage>>> DequeueMessagesIntern
operationName: Constants.Queue.DequeueMessageOperationName,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
return new Response<DequeuedMessage[]>(dequeuedMessage.GetRawResponse(), dequeuedMessage.Value.ToArray());
}
catch (Exception ex)
{
Expand Down Expand Up @@ -1100,9 +1101,9 @@ private async Task<Response<IEnumerable<DequeuedMessage>>> DequeueMessagesIntern
/// Optional <see cref="CancellationToken"/>
/// </param>
/// <returns>
/// <see cref="Response{T}"/> of <see cref="IEnumerable{PeekedMessage}"/>
/// <see cref="Response{T}"/> where T is an array of <see cref="PeekedMessage"/>
/// </returns>
public virtual Response<IEnumerable<PeekedMessage>> PeekMessages(
public virtual Response<PeekedMessage[]> PeekMessages(
int? maxMessages = default,
CancellationToken cancellationToken = default) =>
PeekMessagesInternal(
Expand All @@ -1123,9 +1124,9 @@ public virtual Response<IEnumerable<PeekedMessage>> PeekMessages(
/// Optional <see cref="CancellationToken"/>
/// </param>
/// <returns>
/// <see cref="Response{T}"/> of <see cref="IEnumerable{PeekedMessage}"/>
/// <see cref="Response{T}"/> where T is an array of <see cref="PeekedMessage"/>
/// </returns>
public virtual async Task<Response<IEnumerable<PeekedMessage>>> PeekMessagesAsync(
public virtual async Task<Response<PeekedMessage[]>> PeekMessagesAsync(
int? maxMessages = default,
CancellationToken cancellationToken = default) =>
await PeekMessagesInternal(
Expand All @@ -1149,9 +1150,9 @@ await PeekMessagesInternal(
/// Optional <see cref="CancellationToken"/>
/// </param>
/// <returns>
/// <see cref="Response{T}"/> of <see cref="IEnumerable{PeekedMessage}"/>
/// <see cref="Response{T}"/> where T is an array of <see cref="PeekedMessage"/>
/// </returns>
private async Task<Response<IEnumerable<PeekedMessage>>> PeekMessagesInternal(
private async Task<Response<PeekedMessage[]>> PeekMessagesInternal(
int? maxMessages,
bool async,
CancellationToken cancellationToken)
Expand All @@ -1165,14 +1166,15 @@ private async Task<Response<IEnumerable<PeekedMessage>>> PeekMessagesInternal(
$"{nameof(maxMessages)}: {maxMessages}");
try
{
return await QueueRestClient.Messages.PeekAsync(
var peekedMessages = await QueueRestClient.Messages.PeekAsync(
Pipeline,
MessagesUri,
numberOfMessages: maxMessages,
async: async,
operationName: Constants.Queue.PeekMessagesOperationName,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
return new Response<PeekedMessage[]>(peekedMessages.GetRawResponse(), peekedMessages.Value.ToArray());
}
catch (Exception ex)
{
Expand Down
8 changes: 4 additions & 4 deletions sdk/storage/Azure.Storage.Queues/tests/MessageClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task DequeueAsync()
await queue.EnqueueMessageAsync(GetNewString());

// Act
Response<System.Collections.Generic.IEnumerable<Models.DequeuedMessage>> response = await queue.DequeueMessagesAsync(
Response<Models.DequeuedMessage[]> response = await queue.DequeueMessagesAsync(
maxMessages: 2,
visibilityTimeout: new TimeSpan(1, 0, 0));

Expand All @@ -96,7 +96,7 @@ public async Task DequeueAsync_Min()
await queue.EnqueueMessageAsync(GetNewString());

// Act
Response<System.Collections.Generic.IEnumerable<Models.DequeuedMessage>> response = await queue.DequeueMessagesAsync();
Response<Models.DequeuedMessage[]> response = await queue.DequeueMessagesAsync();

// Assert
Assert.AreEqual(1, response.Value.Count());
Expand Down Expand Up @@ -129,7 +129,7 @@ public async Task PeekAsync()
await queue.EnqueueMessageAsync(GetNewString());

// Act
Response<System.Collections.Generic.IEnumerable<Models.PeekedMessage>> response = await queue.PeekMessagesAsync(maxMessages: 2);
Response<Models.PeekedMessage[]> response = await queue.PeekMessagesAsync(maxMessages: 2);

// Assert
Assert.AreEqual(2, response.Value.Count());
Expand All @@ -147,7 +147,7 @@ public async Task PeekAsync_Min()
await queue.EnqueueMessageAsync(GetNewString());

// Act
Response<System.Collections.Generic.IEnumerable<Models.PeekedMessage>> response = await queue.PeekMessagesAsync();
Response<Models.PeekedMessage[]> response = await queue.PeekMessagesAsync();

// Assert
Assert.AreEqual(1, response.Value.Count());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public async Task UpdateAsync_UpdatePeek()
await queue.UpdateMessageAsync(message1, enqueuedMessage.MessageId, enqueuedMessage.PopReceipt);

// Assert
Response<System.Collections.Generic.IEnumerable<Models.PeekedMessage>> peekedMessages = await queue.PeekMessagesAsync(1);
Response<Models.PeekedMessage[]> peekedMessages = await queue.PeekMessagesAsync(1);
Models.PeekedMessage peekedMessage = peekedMessages.Value.First();

Assert.AreEqual(1, peekedMessages.Value.Count());
Expand Down