Add support for nullable enums to cli options parsing#78
Merged
darthsharp merged 1 commit intomainfrom Feb 14, 2026
Merged
Conversation
- Updated `TestOptionWithEnum` to include `NullableEnumValue` property. - Extended `OptionParserTests` to validate parsing nullable enum options. -
Contributor
There was a problem hiding this comment.
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
CliValueConvertersto 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.