这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: Add .ConfigureAwait(false) to all async call #109

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

Merged
merged 1 commit into from
Aug 30, 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
12 changes: 8 additions & 4 deletions FirebaseAdmin/FirebaseAdmin/Auth/FirebaseAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public static FirebaseAuth GetAuth(FirebaseApp app)
/// 128 characters.</param>
public async Task<string> CreateCustomTokenAsync(string uid)
{
return await this.CreateCustomTokenAsync(uid, default(CancellationToken));
return await this.CreateCustomTokenAsync(uid, default(CancellationToken))
.ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -151,7 +152,8 @@ public async Task<string> CreateCustomTokenAsync(string uid)
public async Task<string> CreateCustomTokenAsync(
string uid, CancellationToken cancellationToken)
{
return await this.CreateCustomTokenAsync(uid, null, cancellationToken);
return await this.CreateCustomTokenAsync(uid, null, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -178,7 +180,8 @@ public async Task<string> CreateCustomTokenAsync(
public async Task<string> CreateCustomTokenAsync(
string uid, IDictionary<string, object> developerClaims)
{
return await this.CreateCustomTokenAsync(uid, developerClaims, default(CancellationToken));
return await this.CreateCustomTokenAsync(uid, developerClaims, default(CancellationToken))
.ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -232,7 +235,8 @@ public async Task<string> CreateCustomTokenAsync(
/// <param name="idToken">A Firebase ID token string to parse and verify.</param>
public async Task<FirebaseToken> VerifyIdTokenAsync(string idToken)
{
return await this.VerifyIdTokenAsync(idToken, default(CancellationToken));
return await this.VerifyIdTokenAsync(idToken, default(CancellationToken))
.ConfigureAwait(false);
}

/// <summary>
Expand Down
9 changes: 6 additions & 3 deletions FirebaseAdmin/FirebaseAdmin/Auth/FirebaseUserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ internal async Task<UserRecord> GetUserByIdAsync(
Value = uid,
Label = "uid",
};
return await this.GetUserAsync(query, cancellationToken);
return await this.GetUserAsync(query, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -124,7 +125,8 @@ internal async Task<UserRecord> GetUserByEmailAsync(
Field = "email",
Value = email,
};
return await this.GetUserAsync(query, cancellationToken);
return await this.GetUserAsync(query, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -148,7 +150,8 @@ internal async Task<UserRecord> GetUserByPhoneNumberAsync(
Value = phoneNumber,
Label = "phone number",
};
return await this.GetUserAsync(query, cancellationToken);
return await this.GetUserAsync(query, cancellationToken)
.ConfigureAwait(false);
}

internal PagedAsyncEnumerable<ExportedUserRecords, ExportedUserRecord> ListUsers(
Expand Down
39 changes: 26 additions & 13 deletions FirebaseAdmin/FirebaseAdmin/Messaging/FirebaseMessaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public static FirebaseMessaging GetMessaging(FirebaseApp app)
/// <param name="message">The message to be sent. Must not be null.</param>
public async Task<string> SendAsync(Message message)
{
return await this.SendAsync(message, false);
return await this.SendAsync(message, false)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -111,7 +112,8 @@ public async Task<string> SendAsync(Message message)
/// operation.</param>
public async Task<string> SendAsync(Message message, CancellationToken cancellationToken)
{
return await this.SendAsync(message, false, cancellationToken);
return await this.SendAsync(message, false, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -137,7 +139,8 @@ public async Task<string> SendAsync(Message message, CancellationToken cancellat
/// but it will not be delivered to any actual recipients.</param>
public async Task<string> SendAsync(Message message, bool dryRun)
{
return await this.SendAsync(message, dryRun, default(CancellationToken));
return await this.SendAsync(message, dryRun, default(CancellationToken))
.ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -182,7 +185,8 @@ public async Task<string> SendAsync(
/// outcome.</returns>
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages)
{
return await this.SendAllAsync(messages, false);
return await this.SendAllAsync(messages, false)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -199,7 +203,8 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages)
/// outcome.</returns>
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, CancellationToken cancellationToken)
{
return await this.SendAllAsync(messages, false, cancellationToken);
return await this.SendAllAsync(messages, false, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -217,7 +222,8 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, Can
/// outcome.</returns>
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, bool dryRun)
{
return await this.SendAllAsync(messages, dryRun, default);
return await this.SendAllAsync(messages, dryRun, default)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -237,7 +243,8 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, boo
/// outcome.</returns>
public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, bool dryRun, CancellationToken cancellationToken)
{
return await this.messagingClient.SendAllAsync(messages, dryRun, cancellationToken);
return await this.messagingClient.SendAllAsync(messages, dryRun, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -250,7 +257,8 @@ public async Task<BatchResponse> SendAllAsync(IEnumerable<Message> messages, boo
/// outcome.</returns>
public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message)
{
return await this.SendMulticastAsync(message, false);
return await this.SendMulticastAsync(message, false)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -265,7 +273,8 @@ public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message)
/// outcome.</returns>
public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message, CancellationToken cancellationToken)
{
return await this.SendMulticastAsync(message, false, cancellationToken);
return await this.SendMulticastAsync(message, false, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -285,7 +294,8 @@ public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message, Ca
/// outcome.</returns>
public async Task<BatchResponse> SendMulticastAsync(MulticastMessage message, bool dryRun)
{
return await this.SendMulticastAsync(message, dryRun, default);
return await this.SendMulticastAsync(message, dryRun, default)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -309,7 +319,8 @@ public async Task<BatchResponse> SendMulticastAsync(
MulticastMessage message, bool dryRun, CancellationToken cancellationToken)
{
return await this.SendAllAsync(
message.GetMessageList(), dryRun, cancellationToken).ConfigureAwait(false);
message.GetMessageList(), dryRun, cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -321,7 +332,8 @@ public async Task<BatchResponse> SendMulticastAsync(
public async Task<TopicManagementResponse> SubscribeToTopicAsync(
IReadOnlyList<string> registrationTokens, string topic)
{
return await this.instanceIdClient.SubscribeToTopicAsync(registrationTokens, topic);
return await this.instanceIdClient.SubscribeToTopicAsync(registrationTokens, topic)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -333,7 +345,8 @@ public async Task<TopicManagementResponse> SubscribeToTopicAsync(
public async Task<TopicManagementResponse> UnsubscribeFromTopicAsync(
IReadOnlyList<string> registrationTokens, string topic)
{
return await this.instanceIdClient.UnsubscribeFromTopicAsync(registrationTokens, topic);
return await this.instanceIdClient.UnsubscribeFromTopicAsync(registrationTokens, topic)
.ConfigureAwait(false);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public async Task<BatchResponse> SendAllAsync(

try
{
return await this.SendBatchRequestAsync(copyOfMessages, dryRun, cancellationToken);
return await this.SendBatchRequestAsync(copyOfMessages, dryRun, cancellationToken)
.ConfigureAwait(false);
}
catch (HttpRequestException e)
{
Expand Down Expand Up @@ -192,7 +193,7 @@ private async Task<BatchResponse> SendBatchRequestAsync(
SendResponse sendResponse;
if (error != null)
{
sendResponse = SendResponse.FromException(await this.CreateException(message));
sendResponse = SendResponse.FromException(await this.CreateException(message).ConfigureAwait(false));
}
else if (content != null)
{
Expand Down