Skip to content

Add support for nullable enums to cli options parsing#78

Merged
darthsharp merged 1 commit intomainfrom
feature/clioptionsnullableenum
Feb 14, 2026
Merged

Add support for nullable enums to cli options parsing#78
darthsharp merged 1 commit intomainfrom
feature/clioptionsnullableenum

Conversation

@darthsharp
Copy link
Copy Markdown
Contributor

No description provided.

- Updated `TestOptionWithEnum` to include `NullableEnumValue` property.
- Extended `OptionParserTests` to validate parsing nullable enum options.
-
Copy link
Copy Markdown
Contributor

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

This PR adds support for nullable enums in the CLI options parsing library. Previously, only non-nullable enums were supported. This enhancement allows CLI options to have nullable enum properties, which is useful when an enum value is optional and should remain null if not provided or if an invalid value is specified.

Changes:

  • Added nullable enum property to test data class (TestOptionWithEnum)
  • Added comprehensive tests covering nullable enum parsing scenarios (valid values, invalid values, empty strings, and missing parameters)
  • Updated CliValueConverters to properly handle nullable enums by checking if the underlying type is an enum and routing to the enum converter, with proper handling of conversion failures

Reviewed changes

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

File Description
tests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests/TestData/TestOptionWithEnum.cs Added nullable enum property with OptionParameter attribute
tests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests/OptionParserTests.cs Added comprehensive test cases for nullable enum parsing including valid/invalid values and edge cases
source/SysConsole/CreativeCoders.SysConsole.Cli.Parsing/OptionProperties/CliValueConverters.cs Updated ConvertNullable method to route enum conversion through EnumValueConverter and properly handle ConverterAction.DoNothing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@darthsharp darthsharp merged commit 2a491f6 into main Feb 14, 2026
12 checks passed
@darthsharp darthsharp deleted the feature/clioptionsnullableenum branch February 14, 2026 12:48
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.

2 participants