Browse Source

Use T? on unconstrained type parameters

pull/1083/head
Kévin Chalet 6 years ago
parent
commit
a993f8273d
  1. 1
      Directory.Build.props
  2. 6
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  3. 4
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  4. 4
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  5. 4
      src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
  6. 4
      src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkApplication.cs
  7. 4
      src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkAuthorization.cs
  8. 4
      src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkScope.cs
  9. 4
      src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkToken.cs
  10. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs
  11. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs
  12. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs
  13. 6
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs
  14. 4
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreApplication.cs
  15. 4
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreAuthorization.cs
  16. 4
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreScope.cs
  17. 4
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreToken.cs
  18. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs
  19. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs
  20. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs
  21. 6
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs
  22. 2
      src/OpenIddict.Server/OpenIddictServerBuilder.cs
  23. 2
      src/OpenIddict.Validation/OpenIddictValidationBuilder.cs

1
Directory.Build.props

@ -4,6 +4,7 @@
<PropertyGroup>
<LangVersion>preview</LangVersion>
<AnalysisLevel>preview</AnalysisLevel>
<NoWarn>$(NoWarn);CS1591;NU5118;NU5128</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugSymbols>true</DebugSymbols>

6
src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs

@ -9,6 +9,7 @@ using System.Buffers.Binary;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
@ -22,7 +23,6 @@ using Microsoft.Extensions.Options;
using OpenIddict.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using SR = OpenIddict.Abstractions.OpenIddictResources;
using SuppressMessageAttribute = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute;
#if !SUPPORTS_KEY_DERIVATION_WITH_SPECIFIED_HASH_ALGORITHM
using Org.BouncyCastle.Crypto;
@ -445,7 +445,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return GetAsync((applications, state) => state(applications), query, cancellationToken);
return GetAsync(static (applications, query) => query(applications), query, cancellationToken);
}
/// <summary>
@ -862,7 +862,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return ListAsync((applications, state) => state(applications), query, cancellationToken);
return ListAsync(static (applications, query) => query(applications), query, cancellationToken);
}
/// <summary>

4
src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs

@ -656,7 +656,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return GetAsync((authorizations, state) => state(authorizations), query, cancellationToken);
return GetAsync(static (authorizations, query) => query(authorizations), query, cancellationToken);
}
/// <summary>
@ -893,7 +893,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return ListAsync((authorizations, state) => state(authorizations), query, cancellationToken);
return ListAsync(static (authorizations, query) => query(authorizations), query, cancellationToken);
}
/// <summary>

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

@ -383,7 +383,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return GetAsync((scopes, state) => state(scopes), query, cancellationToken);
return GetAsync(static (scopes, query) => query(scopes), query, cancellationToken);
}
/// <summary>
@ -704,7 +704,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return ListAsync((scopes, state) => state(scopes), query, cancellationToken);
return ListAsync(static (scopes, query) => query(scopes), query, cancellationToken);
}
/// <summary>

4
src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs

@ -622,7 +622,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return GetAsync((tokens, state) => state(tokens), query, cancellationToken);
return GetAsync(static (tokens, query) => query(tokens), query, cancellationToken);
}
/// <summary>
@ -892,7 +892,7 @@ namespace OpenIddict.Core
throw new ArgumentNullException(nameof(query));
}
return ListAsync((tokens, state) => state(tokens), query, cancellationToken);
return ListAsync(static (tokens, query) => query(tokens), query, cancellationToken);
}
/// <summary>

4
src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkApplication.cs

@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@ -74,8 +73,7 @@ namespace OpenIddict.EntityFramework.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current application.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the permissions associated with the

4
src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkAuthorization.cs

@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@ -50,8 +49,7 @@ namespace OpenIddict.EntityFramework.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current authorization.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the additional properties serialized as a JSON object,

4
src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkScope.cs

@ -6,7 +6,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@ -59,8 +58,7 @@ namespace OpenIddict.EntityFramework.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current scope.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the unique name associated with the current scope.

4
src/OpenIddict.EntityFramework.Models/OpenIddictEntityFrameworkToken.cs

@ -6,7 +6,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFramework.Models
{
@ -59,8 +58,7 @@ namespace OpenIddict.EntityFramework.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current token.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the payload of the current token, if applicable.

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs

@ -11,7 +11,6 @@ using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
@ -862,8 +861,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -878,7 +876,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs

@ -11,7 +11,6 @@ using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.Encodings.Web;
@ -820,8 +819,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -836,7 +834,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs

@ -10,7 +10,6 @@ using System.Collections.Immutable;
using System.ComponentModel;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
@ -630,8 +629,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -646,7 +644,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

6
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkTokenStore.cs

@ -11,7 +11,6 @@ using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Encodings.Web;
using System.Text.Json;
@ -848,8 +847,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -864,7 +862,7 @@ namespace OpenIddict.EntityFramework
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

4
src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreApplication.cs

@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models
{
@ -82,8 +81,7 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current application.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the permissions associated with the

4
src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreAuthorization.cs

@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models
{
@ -58,8 +57,7 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current authorization.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the additional properties serialized as a JSON object,

4
src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreScope.cs

@ -6,7 +6,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models
{
@ -59,8 +58,7 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current scope.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the unique name associated with the current scope.

4
src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreToken.cs

@ -6,7 +6,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models
{
@ -67,8 +66,7 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// <summary>
/// Gets or sets the unique identifier associated with the current token.
/// </summary>
[AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
public virtual TKey? Id { get; set; }
/// <summary>
/// Gets or sets the payload of the current token, if applicable.

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
@ -912,8 +911,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -928,7 +926,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.Encodings.Web;
@ -905,8 +904,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -921,7 +919,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs

@ -8,7 +8,6 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
@ -646,8 +645,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -662,7 +660,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

6
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Encodings.Web;
using System.Text.Json;
@ -918,8 +917,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
[return: MaybeNull]
public virtual TKey ConvertIdentifierFromString(string? identifier)
public virtual TKey? ConvertIdentifierFromString(string? identifier)
{
if (string.IsNullOrEmpty(identifier))
{
@ -934,7 +932,7 @@ namespace OpenIddict.EntityFrameworkCore
/// </summary>
/// <param name="identifier">The identifier to convert.</param>
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier)
public virtual string? ConvertIdentifierToString(TKey? identifier)
{
if (Equals(identifier, default(TKey)))
{

2
src/OpenIddict.Server/OpenIddictServerBuilder.cs

@ -6,6 +6,7 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
@ -17,7 +18,6 @@ using Microsoft.IdentityModel.Tokens;
using OpenIddict.Server;
using static OpenIddict.Abstractions.OpenIddictConstants;
using SR = OpenIddict.Abstractions.OpenIddictResources;
using SuppressMessageAttribute = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute;
namespace Microsoft.Extensions.DependencyInjection
{

2
src/OpenIddict.Validation/OpenIddictValidationBuilder.cs

@ -6,6 +6,7 @@
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
@ -16,7 +17,6 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Validation;
using SR = OpenIddict.Abstractions.OpenIddictResources;
using SuppressMessageAttribute = System.Diagnostics.CodeAnalysis.SuppressMessageAttribute;
namespace Microsoft.Extensions.DependencyInjection
{

Loading…
Cancel
Save