Browse Source

Decorate local functions returning IAsyncEnumerable<T> with [EnumeratorCancellation]

pull/951/head
Kévin Chalet 6 years ago
parent
commit
90b1426305
  1. 7
      global.json
  2. 2
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  3. 3
      src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs
  4. 3
      src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs
  5. 6
      src/OpenIddict.MongoDb/Stores/OpenIddictApplicationStore.cs
  6. 14
      src/OpenIddict.MongoDb/Stores/OpenIddictAuthorizationStore.cs
  7. 6
      src/OpenIddict.MongoDb/Stores/OpenIddictScopeStore.cs
  8. 14
      src/OpenIddict.MongoDb/Stores/OpenIddictTokenStore.cs

7
global.json

@ -1,8 +1,11 @@
{
"tools": {
"dotnet": "3.1.201",
"dotnet": "5.0.100-preview.4.20258.7",
"runtimes": {
"aspnetcore": [ "2.1.17" ]
"aspnetcore": [
"2.1.17",
"3.1.4"
]
}
},

2
src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs

@ -528,7 +528,7 @@ namespace OpenIddict.Core
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<string> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<string> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var resources = new HashSet<string>(StringComparer.Ordinal);

3
src/OpenIddict.EntityFramework/OpenIddictEntityFrameworkHelpers.cs

@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using JetBrains.Annotations;
using OpenIddict.EntityFramework;
@ -75,7 +76,7 @@ namespace System.Data.Entity
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<T> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<T> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
foreach (var element in await source.ToListAsync(cancellationToken))
{

3
src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreHelpers.cs

@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
@ -134,7 +135,7 @@ namespace Microsoft.EntityFrameworkCore
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<T> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<T> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
foreach (var element in await source.ToListAsync(cancellationToken))
{

6
src/OpenIddict.MongoDb/Stores/OpenIddictApplicationStore.cs

@ -204,7 +204,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TApplication> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TApplication> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TApplication>(Options.CurrentValue.ApplicationsCollectionName);
@ -233,7 +233,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TApplication> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TApplication> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TApplication>(Options.CurrentValue.ApplicationsCollectionName);
@ -590,7 +590,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TResult> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TResult> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TApplication>(Options.CurrentValue.ApplicationsCollectionName);

14
src/OpenIddict.MongoDb/Stores/OpenIddictAuthorizationStore.cs

@ -162,7 +162,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TAuthorization> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);
@ -205,7 +205,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TAuthorization> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);
@ -255,7 +255,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TAuthorization> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);
@ -308,7 +308,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TAuthorization> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);
@ -343,7 +343,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TAuthorization> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);
@ -395,7 +395,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TAuthorization> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TAuthorization> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);
@ -657,7 +657,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TResult> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TResult> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);

6
src/OpenIddict.MongoDb/Stores/OpenIddictScopeStore.cs

@ -195,7 +195,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TScope> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TScope> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TScope>(Options.CurrentValue.ScopesCollectionName);
@ -225,7 +225,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TScope> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TScope> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TScope>(Options.CurrentValue.ScopesCollectionName);
@ -466,7 +466,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TResult> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TResult> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TScope>(Options.CurrentValue.ScopesCollectionName);

14
src/OpenIddict.MongoDb/Stores/OpenIddictTokenStore.cs

@ -158,7 +158,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TToken> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);
@ -201,7 +201,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TToken> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);
@ -251,7 +251,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TToken> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);
@ -283,7 +283,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TToken> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);
@ -312,7 +312,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TToken> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);
@ -385,7 +385,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TToken> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TToken> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);
@ -718,7 +718,7 @@ namespace OpenIddict.MongoDb
return ExecuteAsync(cancellationToken);
async IAsyncEnumerable<TResult> ExecuteAsync(CancellationToken cancellationToken)
async IAsyncEnumerable<TResult> ExecuteAsync([EnumeratorCancellation] CancellationToken cancellationToken)
{
var database = await Context.GetDatabaseAsync(cancellationToken);
var collection = database.GetCollection<TToken>(Options.CurrentValue.TokensCollectionName);

Loading…
Cancel
Save