Skip to content

Add Nullable<T> support to command parameter parser selection - #575

Merged
ikkentim merged 6 commits into
mainfrom
copilot/add-support-for-nullable-values
May 17, 2026
Merged

ikkentim merged 6 commits into
mainfrom
copilot/add-support-for-nullable-values

Conversation

Copilot AI commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

The command parser factory did not recognize nullable value-type parameters (e.g. int?, float?), which blocked optional nullable command arguments. This change makes parser resolution nullable-aware by reusing existing parsers for the underlying type.

  • Parser factory: nullable-aware type resolution

    • Updated DefaultCommandParameterParserFactory to unwrap Nullable<T> before parser lookup.
    • Existing parser mappings now apply to nullable variants without introducing new parser implementations:
      • int? → IntParser
      • float? → FloatParser
      • double? → DoubleParser
      • bool? → BooleanParser
      • Enum? → EnumParser
  • Test coverage: nullable mapping cases

    • Extended DefaultCommandParameterParserFactoryTests with focused cases for:
      • int?, float?, double?, bool?
      • nullable enum (DayOfWeek?)
    • Ensures nullable mappings stay aligned with non-nullable parser behavior.
  • Integration-style execution coverage

    • Added PlayerCommandServiceTests cases to validate end-to-end behavior from input string through dispatch and execution for:
      • /money 123 → method receives int? value 123
      • /money → method receives default null
    • Confirms returning a boxed int from parsing works correctly when invoking command methods with nullable parameters.

Example usage now supported:

[PlayerCommand]
public void MoneyCommand(Player player, int? money = null) { }

Copilot AI linked an issue May 16, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add support for nullable values in command parser Add Nullable<T> support to command parameter parser selection May 16, 2026
Copilot AI requested a review from ikkentim May 16, 2026 20:17
@ikkentim

Copy link
Copy Markdown
Owner

@copilot it now returns a int for example, will that work properly when put into the command executor? is there a place to put an integration test to test process from input string to executed command?

Copilot AI commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot it now returns a int for example, will that work properly when put into the command executor? is there a place to put an integration test to test process from input string to executed comma...

Yes—this works correctly. A boxed int is valid for an int? parameter during invocation, and I added integration-style tests that cover input string -> dispatch -> execution for Money(Player player, int? money = null). The tests assert both /money 123 and /money paths in PlayerCommandServiceTests (commit 8d70a78).

@ikkentim
ikkentim marked this pull request as ready for review May 17, 2026 13:15
@github-actions

Copy link
Copy Markdown

.NET libraries test results

535 tests   535 ✅  13s ⏱️
  4 suites    0 💤
  4 files      0 ❌

Results for commit 8a65288.

@ikkentim
ikkentim merged commit b9a63ef into main May 17, 2026
2 checks passed
@ikkentim
ikkentim deleted the copilot/add-support-for-nullable-values branch May 17, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for nullable values in command parser

2 participants