docs/articles/nunit-analyzers/NUnit2044.md
| Topic | Value |
|---|---|
| Id | NUnit2044 |
| Severity | Error |
| Enabled | True |
| Category | Assertion |
| Code | DelegateRequiredAnalyzer |
The actual argument needs to be evaluated by the Assert to catch any exceptions.
In order for the Assert.That to catch an exception or a timeout, the code must be
a delegate so it can be evaluated by the method. If the parameter is not a
delegate, it will be evaluated before the call to Assert.That and stop further
execution.
Convert the call into a delegate using a lambda expression or method group.
<!-- start generated config severity -->Configure the severity per project, for more info see MSDN.
# NUnit2044: Non-delegate actual parameter
dotnet_diagnostic.NUnit2044.severity = chosenSeverity
where chosenSeverity can be one of none, silent, suggestion, warning, or error.
#pragma warning disable NUnit2044 // Non-delegate actual parameter
Code violating the rule here
#pragma warning restore NUnit2044 // Non-delegate actual parameter
Or put this at the top of the file to disable all instances.
#pragma warning disable NUnit2044 // Non-delegate actual parameter
[SuppressMessage][System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
"NUnit2044:Non-delegate actual parameter",
Justification = "Reason...")]