A conditional expression tests a value for null and falls back to another, which ?? says directly
What it finds
x != null ? x : fallback and x == null ? fallback : x are x ?? fallback, which also evaluates x only once.
From the rule's source, conditional_null_fallback.rs.
class Names{ string Pick(string name, string fallback) => name != null ? name : fallback;tx0 reports: this falls back when name is null, which ?? says directly string Other(string name, string fallback) => name != null ? fallback : name;} Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:conditional-null-fallback" = "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:conditional-null-fallback] reason="..."tx0 explain tx0/csharp:conditional-null-fallback shows the same in the terminal. Found a false positive? Report it.