Skip to content
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

remove one of the IsMissing extensions and move to ArgumentException.ThrowIfNullOrWhiteSpace #1676

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions identity-server/src/IdentityServer/IdentityServerUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public class IdentityServerUser
/// <param name="subjectId">The subject ID</param>
public IdentityServerUser(string subjectId)
{
if (subjectId.IsMissing()) throw new ArgumentException("SubjectId is mandatory", nameof(subjectId));

ArgumentException.ThrowIfNullOrWhiteSpace(subjectId);
SubjectId = subjectId;
}

Expand All @@ -71,7 +70,6 @@ public IdentityServerUser(string subjectId)
/// <exception cref="ArgumentNullException"></exception>
public ClaimsPrincipal CreatePrincipal()
{
if (SubjectId.IsMissing()) throw new ArgumentException("SubjectId is mandatory", nameof(SubjectId));
var claims = new List<Claim> { new Claim(JwtClaimTypes.Subject, SubjectId) };

if (DisplayName.IsPresent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public IsActiveContext(ClaimsPrincipal subject, Client client, string caller)
{
ArgumentNullException.ThrowIfNull(subject);
ArgumentNullException.ThrowIfNull(client);
if (caller.IsMissing()) throw new ArgumentNullException(nameof(caller));
ArgumentNullException.ThrowIfNullOrWhiteSpace(caller);

Subject = subject;
Client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected DefaultGrantStore(string grantType,
IHandleGenerationService handleGenerationService,
ILogger logger)
{
if (grantType.IsMissing()) throw new ArgumentNullException(nameof(grantType));
ArgumentException.ThrowIfNullOrWhiteSpace(grantType);

GrantType = grantType;
Store = store;
Expand Down
6 changes: 0 additions & 6 deletions identity-server/src/Storage/Extensions/StringsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ namespace Duende.IdentityServer.Extensions;

internal static class StringExtensions
{
[DebuggerStepThrough]
public static bool IsMissing(this string value)
{
return string.IsNullOrWhiteSpace(value);
}

[DebuggerStepThrough]
public static bool IsPresent(this string value)
{
Expand Down
3 changes: 1 addition & 2 deletions identity-server/src/Storage/IdentityServerUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal class IdentityServerUser
/// <param name="subjectId">The subject ID</param>
public IdentityServerUser(string subjectId)
{
if (subjectId.IsMissing()) throw new ArgumentException("SubjectId is mandatory", nameof(subjectId));
ArgumentException.ThrowIfNullOrWhiteSpace(subjectId);

SubjectId = subjectId;
}
Expand All @@ -66,7 +66,6 @@ public IdentityServerUser(string subjectId)
/// <exception cref="ArgumentNullException"></exception>
public ClaimsPrincipal CreatePrincipal()
{
if (SubjectId.IsMissing()) throw new ArgumentException("SubjectId is mandatory", nameof(SubjectId));
var claims = new List<Claim> { new Claim(JwtClaimTypes.Subject, SubjectId) };

if (DisplayName.IsPresent())
Expand Down
2 changes: 1 addition & 1 deletion identity-server/src/Storage/Models/ApiResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public ApiResource(string name, IEnumerable<string> userClaims)
/// <exception cref="System.ArgumentNullException">name</exception>
public ApiResource(string name, string? displayName, IEnumerable<string>? userClaims)
{
if (name.IsMissing()) throw new ArgumentNullException(nameof(name));
ArgumentException.ThrowIfNullOrWhiteSpace(name);

Name = name;
DisplayName = displayName;
Expand Down
2 changes: 1 addition & 1 deletion identity-server/src/Storage/Models/ApiScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public ApiScope(string name, IEnumerable<string> userClaims)
/// <exception cref="System.ArgumentNullException">name</exception>
public ApiScope(string name, string displayName, IEnumerable<string>? userClaims)
{
if (name.IsMissing()) throw new ArgumentNullException(nameof(name));
ArgumentException.ThrowIfNullOrWhiteSpace(name);

Name = name;
DisplayName = displayName;
Expand Down
2 changes: 1 addition & 1 deletion identity-server/src/Storage/Models/IdentityResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public IdentityResource(string name, IEnumerable<string> userClaims)
/// <exception cref="System.ArgumentException">Must provide at least one claim type - claimTypes</exception>
public IdentityResource(string name, string displayName, IEnumerable<string> userClaims)
{
if (name.IsMissing()) throw new ArgumentNullException(nameof(name));
ArgumentException.ThrowIfNullOrWhiteSpace(name);
if (userClaims.IsNullOrEmpty()) throw new ArgumentException("Must provide at least one claim type", nameof(userClaims));

Name = name;
Expand Down