diff --git a/docs/articles/nunit/V5BreakingChanges.md b/docs/articles/nunit/V5BreakingChanges.md index 208720b3f..d8714bb56 100644 --- a/docs/articles/nunit/V5BreakingChanges.md +++ b/docs/articles/nunit/V5BreakingChanges.md @@ -127,6 +127,25 @@ Issue [#3669](https://github.com/nunit/nunit/issues/3669) | `NETCore` | modern .NET | modern .NET | | `DotNETCore` | modern .NET | modern .NET | +### Has.One.Matches changed predicate type to nullable. + +Issue [#5453](https://github.com/nunit/nunit/issues/5453) + +* **Why:** Aligning actual and expected type at compile-time, as lists can still have null values in them in certain cases. +* **What changed:** Has.One.Matches changed predicate type to nullable. This breaks build if nullable-warnings are treated as errors. `nullable` +* **What to do:** Predicates need to be change to handle potentially null-values: + +```csharp +List testList = ["hello", "world"]; +// NUnit 4 +Assert.That(testList, Has.One.Matches(word => word.Length == 5)); + +// NUnit 4 +Assert.That(testList, Has.One.Matches(word => word?.Length == 5)); //Safe-Navigation +// or +Assert.That(testList, Has.One.Matches(word => word!.Length == 5)); //Null-Forgiving +``` + ## Platform changes ### .NET 6 target removed diff --git a/docs/articles/nunit/release-notes/framework.md b/docs/articles/nunit/release-notes/framework.md index bf03a48d5..9aef68aa1 100644 --- a/docs/articles/nunit/release-notes/framework.md +++ b/docs/articles/nunit/release-notes/framework.md @@ -87,6 +87,7 @@ There are in total 48 issues fixed in this release. ### The following issues are marked as breaking changes +* [5453](https://github.com/nunit/nunit/issues/5453) Has.One.Matches changed predicate type to nullable. (only if nullable-warnings are treated as errors) * [5373](https://github.com/nunit/nunit/issues/5373) Eliminate forced stop from the API. Thanks to NUnit Team member [Manfred Brands](https://github.com/manfred-brands) for [PR 5374](https://github.com/nunit/nunit/pull/5374) * [5367](https://github.com/nunit/nunit/issues/5367) Eliminate StopRun(bool) method from .NET Core builds. Thanks to [CharliePoole](https://github.com/CharliePoole) for [PR 5369](https://github.com/nunit/nunit/pull/5369) * [5323](https://github.com/nunit/nunit/issues/5323) Report compiler error when asserting non-attribute in `Has.Attribute<T>()`. Thanks to NUnit Team member [Steven Weerdenburg](https://github.com/stevenaw) for [PR 5322](https://github.com/nunit/nunit/pull/5322)