Skip to content

feat: add null-safe TryFromValue signature and tests#577

Open
teesofttech wants to merge 2 commits into
ardalis:mainfrom
teesofttech:main
Open

feat: add null-safe TryFromValue signature and tests#577
teesofttech wants to merge 2 commits into
ardalis:mainfrom
teesofttech:main

Conversation

@teesofttech

Copy link
Copy Markdown

feat: add null-safe TryFromValue signature and tests

Copilot AI review requested due to automatic review settings July 4, 2026 17:17

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the SmartEnum<TEnum, TValue>.TryFromValue API to be null-safe and adds unit tests covering TryFromValue behavior for both int-backed and string-backed smart enums.

Changes:

  • Update TryFromValue to accept nullable input (TValue?) and avoid exceptions on null input.
  • Add new unit tests validating TryFromValue success/failure cases for value and string enums.

Reviewed changes

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

File Description
src/SmartEnum/SmartEnum.cs Adjusts TryFromValue signature/implementation to handle nullable inputs.
test/SmartEnum.UnitTests/SmartEnumTryFromValue.cs Adds tests exercising TryFromValue behavior for matching/non-matching values and null string input.

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

Comment thread src/SmartEnum/SmartEnum.cs Outdated
Comment thread test/SmartEnum.UnitTests/SmartEnumTryFromValue.cs
@teesofttech

Copy link
Copy Markdown
Author

@ardalis Can you review this PR please

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