Skip to content

refactor: use nameof() in ArgumentNullException throws#815

Merged
louis1706 merged 1 commit intoExMod-Team:masterfrom
intjiraya:refactor/use-nameof-in-argumentnullexception
May 3, 2026
Merged

refactor: use nameof() in ArgumentNullException throws#815
louis1706 merged 1 commit intoExMod-Team:masterfrom
intjiraya:refactor/use-nameof-in-argumentnullexception

Conversation

@intjiraya
Copy link
Copy Markdown

@intjiraya intjiraya commented May 3, 2026

Description

Describe the changes

Replaces hardcoded string literals with nameof() expressions in ArgumentNullException throws so the parameter names stay in sync if the underlying parameter or property is ever renamed.

Files touched:

  • Exiled.CustomItems/API/Extensions.cs - Register and Unregister (x2)
  • Exiled.Loader/Features/Configs/CommentGatheringTypeInspector.cs - constructor (x1)
  • Exiled.API/Features/GlobalPatchProcessor.cs - PatchAll and UnpatchAll (x2)

For GlobalPatchProcessor, the literal "GroupId" referenced the property PatchGroupAttribute.GroupId (the value being checked is patchGroup.GroupId); switched to nameof(patchGroup.GroupId) to preserve the same string while making it refactor-safe.

What is the current behavior?

Throws ArgumentNullException with hardcoded string literals as parameter names.

What is the new behavior? (if this is a feature change)

Same exception, same parameter name string, just sourced via nameof().

Does this PR introduce a breaking change?

No.

Other information:

N/A.


Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentations

Submission checklist

  • I have checked the project can be compiled
  • I have tested my changes and it worked as expected

Patches (if there are any changes related to Harmony patches)

  • I have checked no IL patching errors in the console

Other

  • Still requires more testing

Copilot AI review requested due to automatic review settings May 3, 2026 00:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors ArgumentNullException throws to use nameof(...) instead of hardcoded parameter-name strings, ensuring exception parameter names remain refactor-safe across the codebase.

Changes:

  • Replace "innerTypeDescriptor" with nameof(innerTypeDescriptor) in CommentGatheringTypeInspector.
  • Replace "customItems" with nameof(customItems) in CustomItems extension methods.
  • Replace "GroupId" with nameof(patchGroup.GroupId) in GlobalPatchProcessor patch group validation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
EXILED/Exiled.Loader/Features/Configs/CommentGatheringTypeInspector.cs Uses nameof(...) for constructor null-guard parameter naming.
EXILED/Exiled.CustomItems/API/Extensions.cs Uses nameof(...) for customItems null checks in Register/Unregister.
EXILED/Exiled.API/Features/GlobalPatchProcessor.cs Uses nameof(...) for patch group GroupId null/empty validation exceptions.

@louis1706 louis1706 merged commit f3b187e into ExMod-Team:master May 3, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants