diff --git a/identity-server/src/Storage/Models/Resources.cs b/identity-server/src/Storage/Models/Resources.cs index 3589b3072..1fde995e7 100644 --- a/identity-server/src/Storage/Models/Resources.cs +++ b/identity-server/src/Storage/Models/Resources.cs @@ -19,6 +19,9 @@ public class Resources /// public Resources() { + IdentityResources = new HashSet(); + ApiResources = new HashSet(); + ApiScopes = new HashSet(); } /// @@ -37,20 +40,11 @@ public Resources(Resources other) /// The identity resources. /// The API resources. /// The API scopes. - public Resources(IEnumerable identityResources, IEnumerable apiResources, IEnumerable apiScopes) + public Resources(IEnumerable? identityResources, IEnumerable? apiResources, IEnumerable? apiScopes) { - if (identityResources?.Any() == true) - { - IdentityResources = identityResources.ToHashSet(); - } - if (apiResources?.Any() == true) - { - ApiResources = apiResources.ToHashSet(); - } - if (apiScopes?.Any() == true) - { - ApiScopes = apiScopes.ToHashSet(); - } + IdentityResources = identityResources?.ToHashSet() ?? new HashSet(); + ApiResources = apiResources?.ToHashSet() ?? new HashSet(); + ApiScopes = apiScopes?.ToHashSet() ?? new HashSet(); } /// @@ -64,15 +58,15 @@ public Resources(IEnumerable identityResources, IEnumerable /// Gets or sets the identity resources. /// - public ICollection IdentityResources { get; set; } = new HashSet(); + public ICollection IdentityResources { get; set; } /// /// Gets or sets the API resources. /// - public ICollection ApiResources { get; set; } = new HashSet(); + public ICollection ApiResources { get; set; } /// /// Gets or sets the API scopes. /// - public ICollection ApiScopes { get; set; } = new HashSet(); + public ICollection ApiScopes { get; set; } }