docs/articles/nunit-analyzers/NUnit2025.md
| Topic | Value |
|---|---|
| Id | NUnit2025 |
| Severity | Hidden |
| Enabled | False |
| Category | Assertion |
| Code | ContainsConstraintWrongActualTypeAnalyzer |
The ContainsConstraint requires the type of the actual value to be either a string or a collection of strings.
Using a ContainsConstraint with an actual argument, which is neither a string nor a collection of strings, leads to an assertion error.
Fix the actual value or use appropriate constraint.
<!-- start generated config severity -->Configure the severity per project, for more info see MSDN.
# NUnit2025: Wrong actual type used with ContainsConstraint
dotnet_diagnostic.NUnit2025.severity = chosenSeverity
where chosenSeverity can be one of none, silent, suggestion, warning, or error.
#pragma warning disable NUnit2025 // Wrong actual type used with ContainsConstraint
Code violating the rule here
#pragma warning restore NUnit2025 // Wrong actual type used with ContainsConstraint
Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit2025 // Wrong actual type used with ContainsConstraint
[SuppressMessage][System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
"NUnit2025:Wrong actual type used with ContainsConstraint",
Justification = "Reason...")]