docs/articles/nunit-analyzers/NUnit2024.md
| Topic | Value |
|---|---|
| Id | NUnit2024 |
| Severity | Error |
| Enabled | True |
| Category | Assertion |
| Code | StringConstraintWrongActualTypeAnalyzer |
The type of the actual argument is not a string and hence cannot be used with a String Constraint.
Assertions with string constraints and non-string actual value will fail with error.
Fix actual value or use appropriate constraint.
<!-- start generated config severity -->Configure the severity per project, for more info see MSDN.
# NUnit2024: Wrong actual type used with String Constraint
dotnet_diagnostic.NUnit2024.severity = chosenSeverity
where chosenSeverity can be one of none, silent, suggestion, warning, or error.
#pragma warning disable NUnit2024 // Wrong actual type used with String Constraint
Code violating the rule here
#pragma warning restore NUnit2024 // Wrong actual type used with String Constraint
Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit2024 // Wrong actual type used with String Constraint
[SuppressMessage][System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
"NUnit2024:Wrong actual type used with String Constraint",
Justification = "Reason...")]