Browse Source

Add nullable annotations to OpenIddict.EntityFrameworkCore.Models

pull/1038/head
Kévin Chalet 6 years ago
parent
commit
eb4271d678
  1. 1
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddict.EntityFrameworkCore.Models.csproj
  2. 48
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreApplication.cs
  3. 26
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreAuthorization.cs
  4. 32
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreScope.cs
  5. 36
      src/OpenIddict.EntityFrameworkCore.Models/OpenIddictEntityFrameworkCoreToken.cs

1
src/OpenIddict.EntityFrameworkCore.Models/OpenIddict.EntityFrameworkCore.Models.csproj

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks> <TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

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

@ -7,6 +7,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models namespace OpenIddict.EntityFrameworkCore.Models
{ {
@ -34,7 +35,10 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// Represents an OpenIddict application. /// Represents an OpenIddict application.
/// </summary> /// </summary>
[DebuggerDisplay("Id = {Id.ToString(),nq} ; ClientId = {ClientId,nq} ; Type = {Type,nq}")] [DebuggerDisplay("Id = {Id.ToString(),nq} ; ClientId = {ClientId,nq} ; Type = {Type,nq}")]
public class OpenIddictEntityFrameworkCoreApplication<TKey, TAuthorization, TToken> where TKey : IEquatable<TKey> public class OpenIddictEntityFrameworkCoreApplication<TKey, TAuthorization, TToken>
where TKey : IEquatable<TKey>
where TAuthorization : class
where TToken : class
{ {
/// <summary> /// <summary>
/// Gets the list of the authorizations associated with this application. /// Gets the list of the authorizations associated with this application.
@ -42,77 +46,74 @@ namespace OpenIddict.EntityFrameworkCore.Models
public virtual ICollection<TAuthorization> Authorizations { get; } = new HashSet<TAuthorization>(); public virtual ICollection<TAuthorization> Authorizations { get; } = new HashSet<TAuthorization>();
/// <summary> /// <summary>
/// Gets or sets the client identifier /// Gets or sets the client identifier associated with the current application.
/// associated with the current application.
/// </summary> /// </summary>
public virtual string ClientId { get; set; } public virtual string? ClientId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the client secret associated with the current application. /// Gets or sets the client secret associated with the current application.
/// Note: depending on the application manager used to create this instance, /// Note: depending on the application manager used to create this instance,
/// this property may be hashed or encrypted for security reasons. /// this property may be hashed or encrypted for security reasons.
/// </summary> /// </summary>
public virtual string ClientSecret { get; set; } public virtual string? ClientSecret { get; set; }
/// <summary> /// <summary>
/// Gets or sets the concurrency token. /// Gets or sets the concurrency token.
/// </summary> /// </summary>
public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
/// <summary> /// <summary>
/// Gets or sets the consent type /// Gets or sets the consent type associated with the current application.
/// associated with the current application.
/// </summary> /// </summary>
public virtual string ConsentType { get; set; } public virtual string? ConsentType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the display name /// Gets or sets the display name associated with the current application.
/// associated with the current application.
/// </summary> /// </summary>
public virtual string DisplayName { get; set; } public virtual string? DisplayName { get; set; }
/// <summary> /// <summary>
/// Gets or sets the localized display names /// Gets or sets the localized display names
/// associated with the current application, /// associated with the current application,
/// serialized as a JSON object. /// serialized as a JSON object.
/// </summary> /// </summary>
public virtual string DisplayNames { get; set; } public virtual string? DisplayNames { get; set; }
/// <summary> /// <summary>
/// Gets or sets the unique identifier /// Gets or sets the unique identifier associated with the current application.
/// associated with the current application.
/// </summary> /// </summary>
public virtual TKey Id { get; set; } [AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
/// <summary> /// <summary>
/// Gets or sets the permissions associated with the /// Gets or sets the permissions associated with the
/// current application, serialized as a JSON array. /// current application, serialized as a JSON array.
/// </summary> /// </summary>
public virtual string Permissions { get; set; } public virtual string? Permissions { get; set; }
/// <summary> /// <summary>
/// Gets or sets the logout callback URLs associated with /// Gets or sets the logout callback URLs associated with
/// the current application, serialized as a JSON array. /// the current application, serialized as a JSON array.
/// </summary> /// </summary>
public virtual string PostLogoutRedirectUris { get; set; } public virtual string? PostLogoutRedirectUris { get; set; }
/// <summary> /// <summary>
/// Gets or sets the additional properties serialized as a JSON object, /// Gets or sets the additional properties serialized as a JSON object,
/// or <c>null</c> if no bag was associated with the current application. /// or <c>null</c> if no bag was associated with the current application.
/// </summary> /// </summary>
public virtual string Properties { get; set; } public virtual string? Properties { get; set; }
/// <summary> /// <summary>
/// Gets or sets the callback URLs associated with the /// Gets or sets the callback URLs associated with the
/// current application, serialized as a JSON array. /// current application, serialized as a JSON array.
/// </summary> /// </summary>
public virtual string RedirectUris { get; set; } public virtual string? RedirectUris { get; set; }
/// <summary> /// <summary>
/// Gets or sets the requirements associated with the /// Gets or sets the requirements associated with the
/// current application, serialized as a JSON array. /// current application, serialized as a JSON array.
/// </summary> /// </summary>
public virtual string Requirements { get; set; } public virtual string? Requirements { get; set; }
/// <summary> /// <summary>
/// Gets the list of the tokens associated with this application. /// Gets the list of the tokens associated with this application.
@ -120,9 +121,8 @@ namespace OpenIddict.EntityFrameworkCore.Models
public virtual ICollection<TToken> Tokens { get; } = new HashSet<TToken>(); public virtual ICollection<TToken> Tokens { get; } = new HashSet<TToken>();
/// <summary> /// <summary>
/// Gets or sets the application type /// Gets or sets the application type associated with the current application.
/// associated with the current application.
/// </summary> /// </summary>
public virtual string Type { get; set; } public virtual string? Type { get; set; }
} }
} }

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

@ -7,6 +7,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models namespace OpenIddict.EntityFrameworkCore.Models
{ {
@ -34,45 +35,48 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// Represents an OpenIddict authorization. /// Represents an OpenIddict authorization.
/// </summary> /// </summary>
[DebuggerDisplay("Id = {Id.ToString(),nq} ; Subject = {Subject,nq} ; Type = {Type,nq} ; Status = {Status,nq}")] [DebuggerDisplay("Id = {Id.ToString(),nq} ; Subject = {Subject,nq} ; Type = {Type,nq} ; Status = {Status,nq}")]
public class OpenIddictEntityFrameworkCoreAuthorization<TKey, TApplication, TToken> where TKey : IEquatable<TKey> public class OpenIddictEntityFrameworkCoreAuthorization<TKey, TApplication, TToken>
where TKey : IEquatable<TKey>
where TApplication : class
where TToken : class
{ {
/// <summary> /// <summary>
/// Gets or sets the application associated with the current authorization. /// Gets or sets the application associated with the current authorization.
/// </summary> /// </summary>
public virtual TApplication Application { get; set; } public virtual TApplication? Application { get; set; }
/// <summary> /// <summary>
/// Gets or sets the concurrency token. /// Gets or sets the concurrency token.
/// </summary> /// </summary>
public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
/// <summary> /// <summary>
/// Gets or sets the unique identifier /// Gets or sets the unique identifier associated with the current authorization.
/// associated with the current authorization.
/// </summary> /// </summary>
public virtual TKey Id { get; set; } [AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
/// <summary> /// <summary>
/// Gets or sets the additional properties serialized as a JSON object, /// Gets or sets the additional properties serialized as a JSON object,
/// or <c>null</c> if no bag was associated with the current authorization. /// or <c>null</c> if no bag was associated with the current authorization.
/// </summary> /// </summary>
public virtual string Properties { get; set; } public virtual string? Properties { get; set; }
/// <summary> /// <summary>
/// Gets or sets the scopes associated with the current /// Gets or sets the scopes associated with the current
/// authorization, serialized as a JSON array. /// authorization, serialized as a JSON array.
/// </summary> /// </summary>
public virtual string Scopes { get; set; } public virtual string? Scopes { get; set; }
/// <summary> /// <summary>
/// Gets or sets the status of the current authorization. /// Gets or sets the status of the current authorization.
/// </summary> /// </summary>
public virtual string Status { get; set; } public virtual string? Status { get; set; }
/// <summary> /// <summary>
/// Gets or sets the subject associated with the current authorization. /// Gets or sets the subject associated with the current authorization.
/// </summary> /// </summary>
public virtual string Subject { get; set; } public virtual string? Subject { get; set; }
/// <summary> /// <summary>
/// Gets the list of tokens associated with the current authorization. /// Gets the list of tokens associated with the current authorization.
@ -82,6 +86,6 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// <summary> /// <summary>
/// Gets or sets the type of the current authorization. /// Gets or sets the type of the current authorization.
/// </summary> /// </summary>
public virtual string Type { get; set; } public virtual string? Type { get; set; }
} }
} }

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

@ -6,6 +6,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models namespace OpenIddict.EntityFrameworkCore.Models
{ {
@ -30,55 +31,52 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// <summary> /// <summary>
/// Gets or sets the concurrency token. /// Gets or sets the concurrency token.
/// </summary> /// </summary>
public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
/// <summary> /// <summary>
/// Gets or sets the public description /// Gets or sets the public description associated with the current scope.
/// associated with the current scope.
/// </summary> /// </summary>
public virtual string Description { get; set; } public virtual string? Description { get; set; }
/// <summary> /// <summary>
/// Gets or sets the localized public descriptions associated /// Gets or sets the localized public descriptions associated
/// with the current scope, serialized as a JSON object. /// with the current scope, serialized as a JSON object.
/// </summary> /// </summary>
public virtual string Descriptions { get; set; } public virtual string? Descriptions { get; set; }
/// <summary> /// <summary>
/// Gets or sets the display name /// Gets or sets the display name associated with the current scope.
/// associated with the current scope.
/// </summary> /// </summary>
public virtual string DisplayName { get; set; } public virtual string? DisplayName { get; set; }
/// <summary> /// <summary>
/// Gets or sets the localized display names /// Gets or sets the localized display names
/// associated with the current application, /// associated with the current application,
/// serialized as a JSON object. /// serialized as a JSON object.
/// </summary> /// </summary>
public virtual string DisplayNames { get; set; } public virtual string? DisplayNames { get; set; }
/// <summary> /// <summary>
/// Gets or sets the unique identifier /// Gets or sets the unique identifier associated with the current scope.
/// associated with the current scope.
/// </summary> /// </summary>
public virtual TKey Id { get; set; } [AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
/// <summary> /// <summary>
/// Gets or sets the unique name /// Gets or sets the unique name associated with the current scope.
/// associated with the current scope.
/// </summary> /// </summary>
public virtual string Name { get; set; } public virtual string? Name { get; set; }
/// <summary> /// <summary>
/// Gets or sets the additional properties serialized as a JSON object, /// Gets or sets the additional properties serialized as a JSON object,
/// or <c>null</c> if no bag was associated with the current scope. /// or <c>null</c> if no bag was associated with the current scope.
/// </summary> /// </summary>
public virtual string Properties { get; set; } public virtual string? Properties { get; set; }
/// <summary> /// <summary>
/// Gets or sets the resources associated with the /// Gets or sets the resources associated with the
/// current scope, serialized as a JSON array. /// current scope, serialized as a JSON array.
/// </summary> /// </summary>
public virtual string Resources { get; set; } public virtual string? Resources { get; set; }
} }
} }

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

@ -6,6 +6,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace OpenIddict.EntityFrameworkCore.Models namespace OpenIddict.EntityFrameworkCore.Models
{ {
@ -33,53 +34,54 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// Represents an OpenIddict token. /// Represents an OpenIddict token.
/// </summary> /// </summary>
[DebuggerDisplay("Id = {Id.ToString(),nq} ; Subject = {Subject,nq} ; Type = {Type,nq} ; Status = {Status,nq}")] [DebuggerDisplay("Id = {Id.ToString(),nq} ; Subject = {Subject,nq} ; Type = {Type,nq} ; Status = {Status,nq}")]
public class OpenIddictEntityFrameworkCoreToken<TKey, TApplication, TAuthorization> where TKey : IEquatable<TKey> public class OpenIddictEntityFrameworkCoreToken<TKey, TApplication, TAuthorization>
where TKey : IEquatable<TKey>
where TApplication : class
where TAuthorization : class
{ {
/// <summary> /// <summary>
/// Gets or sets the application associated with the current token. /// Gets or sets the application associated with the current token.
/// </summary> /// </summary>
public virtual TApplication Application { get; set; } public virtual TApplication? Application { get; set; }
/// <summary> /// <summary>
/// Gets or sets the authorization associated with the current token. /// Gets or sets the authorization associated with the current token.
/// </summary> /// </summary>
public virtual TAuthorization Authorization { get; set; } public virtual TAuthorization? Authorization { get; set; }
/// <summary> /// <summary>
/// Gets or sets the concurrency token. /// Gets or sets the concurrency token.
/// </summary> /// </summary>
public virtual string ConcurrencyToken { get; set; } = Guid.NewGuid().ToString(); public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
/// <summary> /// <summary>
/// Gets or sets the date on which the token /// Gets or sets the date on which the token will start to be considered valid.
/// will start to be considered valid.
/// </summary> /// </summary>
public virtual DateTimeOffset? CreationDate { get; set; } public virtual DateTimeOffset? CreationDate { get; set; }
/// <summary> /// <summary>
/// Gets or sets the date on which the token /// Gets or sets the date on which the token will no longer be considered valid.
/// will no longer be considered valid.
/// </summary> /// </summary>
public virtual DateTimeOffset? ExpirationDate { get; set; } public virtual DateTimeOffset? ExpirationDate { get; set; }
/// <summary> /// <summary>
/// Gets or sets the unique identifier /// Gets or sets the unique identifier associated with the current token.
/// associated with the current token.
/// </summary> /// </summary>
public virtual TKey Id { get; set; } [AllowNull, MaybeNull]
public virtual TKey Id { get; set; } = default!;
/// <summary> /// <summary>
/// Gets or sets the payload of the current token, if applicable. /// Gets or sets the payload of the current token, if applicable.
/// Note: this property is only used for reference tokens /// Note: this property is only used for reference tokens
/// and may be encrypted for security reasons. /// and may be encrypted for security reasons.
/// </summary> /// </summary>
public virtual string Payload { get; set; } public virtual string? Payload { get; set; }
/// <summary> /// <summary>
/// Gets or sets the additional properties serialized as a JSON object, /// Gets or sets the additional properties serialized as a JSON object,
/// or <c>null</c> if no bag was associated with the current token. /// or <c>null</c> if no bag was associated with the current token.
/// </summary> /// </summary>
public virtual string Properties { get; set; } public virtual string? Properties { get; set; }
/// <summary> /// <summary>
/// Gets or sets the reference identifier associated /// Gets or sets the reference identifier associated
@ -87,21 +89,21 @@ namespace OpenIddict.EntityFrameworkCore.Models
/// Note: this property is only used for reference tokens /// Note: this property is only used for reference tokens
/// and may be hashed or encrypted for security reasons. /// and may be hashed or encrypted for security reasons.
/// </summary> /// </summary>
public virtual string ReferenceId { get; set; } public virtual string? ReferenceId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the status of the current token. /// Gets or sets the status of the current token.
/// </summary> /// </summary>
public virtual string Status { get; set; } public virtual string? Status { get; set; }
/// <summary> /// <summary>
/// Gets or sets the subject associated with the current token. /// Gets or sets the subject associated with the current token.
/// </summary> /// </summary>
public virtual string Subject { get; set; } public virtual string? Subject { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of the current token. /// Gets or sets the type of the current token.
/// </summary> /// </summary>
public virtual string Type { get; set; } public virtual string? Type { get; set; }
} }
} }

Loading…
Cancel
Save