An iterator method is called as a statement, so none of its body runs

tx0/csharp:discarded-iterator-calldefaultwarningreliability/collectionsdepth fastbug

What it finds

A method with yield return runs only when its result is enumerated. Calling it and dropping the result does nothing at all, not even the code before the first yield. In Unity code the call was usually meant to be passed to StartCoroutine. The rule reports a call, without receiver or on this, of a method of the same type whose every overload with that name contains yield.

From the rule's source, discarded_iterator_call.rs.

Example from the rule's tests
using System.Collections; class Fader{    void Start()    {        FadeOut();tx0 reports: FadeOut is an iterator; calling it without enumerating the result runs nothing        Run(FadeOut());    }     IEnumerator FadeOut()    {        yield return null;    }     void Run(IEnumerator routine) { }}
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 in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:discarded-iterator-call" = "off"

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:discarded-iterator-call] reason="..."

tx0 explain tx0/csharp:discarded-iterator-call shows the same in the terminal. Found a false positive? Report it.