Skip to content

[KeyBot] improve: standardize argument guards in Authorization ServiceCollectionExtensions#258

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
keybot/improve-argument-guards-20260511-179ad7693539de15
Draft

[KeyBot] improve: standardize argument guards in Authorization ServiceCollectionExtensions#258
github-actions[bot] wants to merge 1 commit into
mainfrom
keybot/improve-argument-guards-20260511-179ad7693539de15

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by KeyBot, an automated AI assistant.

Summary

Replaces verbose if (x is null) { throw new ArgumentNullException(nameof(x)); } patterns with modern ArgumentNullException.ThrowIfNull and ArgumentException.ThrowIfNullOrEmpty helpers in ServiceCollectionExtensions (Authorization project).

Motivation

The first overload of AddKeycloakAuthorization already used the modern throw-helper pattern; the remaining overloads and AddAuthorizationServer/AddAuthorizationServerClient still used the old verbose guards. This aligns the whole file with the idiomatic .NET 7+ style, reduces boilerplate, and makes the intent immediately clear.

Changes

  • AddKeycloakAuthorization(IConfigurationSection) — replaced two if/throw blocks with ArgumentNullException.ThrowIfNull
  • AddKeycloakAuthorization(Action<>) — replaced one if/throw block
  • AddKeycloakAuthorization(IConfiguration, string) — replaced the string.IsNullOrEmpty guard with ArgumentException.ThrowIfNullOrEmpty
  • AddAuthorizationServer(IConfiguration, ...) — replaced two null checks + one string check
  • AddAuthorizationServer(IConfigurationSection, ...) — replaced two null checks
  • AddAuthorizationServer(Action<>, ...) — replaced one null check
  • AddAuthorizationServerClient — replaced one null check

Test Status

✅ Build: dotnet build -p:WarningLevel=0 /clp:ErrorsOnly — succeeded
✅ Unit tests: dotnet cake --target=Test — 155 passed, 0 failed
⏭️ Integration tests: skipped (requires Docker/Testcontainers)

Generated by 🤖 KeyBot. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@1f672aef974f4246124860fc532f82fe8a93a57e

…onExtensions

Replace verbose if/throw null-check patterns with modern
ArgumentNullException.ThrowIfNull and ArgumentException.ThrowIfNullOrEmpty
helpers throughout ServiceCollectionExtensions in the Authorization project.
This aligns with the pattern already used in the first AddKeycloakAuthorization
overload and reduces boilerplate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation Automated changes keybot Created/managed by KeyBot labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes keybot Created/managed by KeyBot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants