Repository navigation
fix: fail HasValue on a null enum subject - #1046
Merged
Merged
Conversation
vbreuss
enabled auto-merge (squash)
September 12, 2026 14:13
Contributor
Test Results 23 files 23 suites 8m 41s ⏱️ Results for commit af25a92. ♻️ This comment has been updated with latest results. |
Contributor
🚀 Benchmark ResultsDetails
|
`Convert.ToInt64(null, CultureInfo.InvariantCulture)` returns `0`, so a `null` subject was treated as an enum with the value `0`: `Expect.That((MyColors?)null).HasValue(0)` succeeded and the corresponding `DoesNotHaveValue(0)` failed, while every other value behaved the other way round. The constraint now checks the subject for `null` first, so `HasValue` always fails and `DoesNotHaveValue` always succeeds for a `null` subject, independent of the expected value.
vbreuss
force-pushed
the
fix/has-value-null-subject
branch
from
September 12, 2026 14:31
30fc274 to
af25a92
Compare
|
github-actions Bot
added a commit
that referenced
this pull request
Sep 12, 2026
…ubject (#1046) by Valentin Breuß
github-actions Bot
added a commit
that referenced
this pull request
Sep 12, 2026
…ubject (#1046) by Valentin Breuß
This was referenced Oct 12, 2026
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.



Convert.ToInt64(null, CultureInfo.InvariantCulture)returns0, so anullsubject was treated as an enum with the value0:Expect.That((MyColors?)null).HasValue(0)succeeded and the correspondingDoesNotHaveValue(0)failed, while every other value behaved the other way round.The constraint now checks the subject for
nullfirst, soHasValuealways fails andDoesNotHaveValuealways succeeds for anullsubject, independent of the expected value.