docs/articles/nunit-analyzers/NUnit2026.md
| Topic | Value |
|---|---|
| Id | NUnit2026 |
| Severity | Error |
| Enabled | True |
| Category | Assertion |
| Code | SomeItemsIncompatibleTypesAnalyzer |
The SomeItemsConstraint with EqualConstraint requires the actual argument to be a collection where the element type can match the type of the expected argument.
Using Does.Contain or Contains.Item constraints with actual argument, which is either not a collection, or has wrong element type, leads to assertion error.
Fix the actual value or use appropriate constraint.
<!-- start generated config severity -->Configure the severity per project, for more info see MSDN.
# NUnit2026: Wrong actual type used with the SomeItemsConstraint with EqualConstraint
dotnet_diagnostic.NUnit2026.severity = chosenSeverity
where chosenSeverity can be one of none, silent, suggestion, warning, or error.
#pragma warning disable NUnit2026 // Wrong actual type used with the SomeItemsConstraint with EqualConstraint
Code violating the rule here
#pragma warning restore NUnit2026 // Wrong actual type used with the SomeItemsConstraint with EqualConstraint
Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit2026 // Wrong actual type used with the SomeItemsConstraint with EqualConstraint
[SuppressMessage][System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
"NUnit2026:Wrong actual type used with the SomeItemsConstraint with EqualConstraint",
Justification = "Reason...")]