Repository navigation
refactor!: accept a null subject on the non-generic collection expectations - #1096
Merged
Merged
Conversation
vbreuss
force-pushed
the
refactor/nullable-non-generic-enumerable-subject
branch
from
September 14, 2026 13:34
d223b19 to
f3c42fc
Compare
Contributor
Contributor
🚀 Benchmark ResultsDetails
|
Contributor
👽 Mutation ResultsaweXpectDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0 |
Base automatically changed from
docs/null-rule-for-extension-authors
to
main
September 14, 2026 14:26
…ations Every other reference-type subject is annotated nullable - `IEnumerable<TItem>` 48 of 48, `string` 29 of 29, `Version` 14 of 14, `Exception` 11 of 11 - but the non-generic `IEnumerable` overloads were annotated non-nullable in 31 of 32 places, `HasItem` being the lone exception. Asserting on a nullable variable through one of them therefore produced a CS8620 at the call site while the identical assertion on the generic overload produced nothing. The warning was misleading rather than protective: the annotation is invisible at runtime, so these overloads were always swept by `GuaranteesNotNullTests` and always failed a null subject with `it was <null>` like everything else. Telling callers not to pass null contradicts the rule that a null subject is an ordinary input which fails cleanly. Widening a parameter of the covariant `IThat<out T>` cannot invalidate an existing caller, so this removes warnings without introducing any.
vbreuss
force-pushed
the
refactor/nullable-non-generic-enumerable-subject
branch
from
September 14, 2026 14:26
f3c42fc to
24a97c0
Compare
vbreuss
deleted the
refactor/nullable-non-generic-enumerable-subject
branch
September 14, 2026 14:27
|
github-actions Bot
added a commit
that referenced
this pull request
Sep 14, 2026
… non-generic collection expectations (#1096) by Valentin Breuß
github-actions Bot
added a commit
that referenced
this pull request
Sep 14, 2026
… non-generic collection expectations (#1096) 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.



Every other reference-type subject is annotated nullable -
IEnumerable<TItem>48 of 48,string29 of 29,Version14 of 14,Exception11 of 11 - but the non-genericIEnumerableoverloads were annotated non-nullable in 31 of 32 places,HasItembeing the lone exception. Asserting on a nullable variable through one of them therefore produced a CS8620 at the call site while the identical assertion on the generic overload produced nothing.The warning was misleading rather than protective: the annotation is invisible at runtime, so these overloads were always swept by
GuaranteesNotNullTestsand always failed a null subject withit was <null>like everything else. Telling callers not to pass null contradicts the rule that a null subject is an ordinary input which fails cleanly.Widening a parameter of the covariant
IThat<out T>cannot invalidate an existing caller, so this removes warnings without introducing any.