The condition of Debug.Assert has an effect, which release builds drop

tx0/csharp:debug-assert-effectrecommendedwarningmaintainability/testsdepth fastbug

What it finds

Calls of Debug.Assert are removed from release builds together with their arguments. Debug.Assert(queue.Remove(item)) therefore removes the item only in debug builds, and the program behaves differently once released. Do the work first, then assert on its result.

From the rule's source, debug_assert_effect.rs.

Example from the rule's tests
using System.Collections.Generic;using System.Diagnostics; class Queue{    void Take(HashSet<int> items, int item, int count)    {        Debug.Assert(items.Remove(item));tx0 reports: items.Remove(item) runs only in debug builds        Debug.Assert(count++ < 10);tx0 reports: count++ runs only in debug builds        Debug.Assert(items.Contains(item));    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:debug-assert-effect" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:debug-assert-effect] reason="..."

tx0 explain tx0/csharp:debug-assert-effect shows the same in the terminal. Found a false positive? Report it.