An unsigned value is tested for being negative or non-negative, which has a fixed answer
What it finds
A variable of type uint, ulong, ushort, byte or nuint is never below zero, so x < 0 is always false and x >= 0 always true. Such a test usually guards against a value that was meant to be signed, or an underflow that has already wrapped around.
From the rule's source, unsigned_sign_test.rs.
class Sizes{ bool Bad(uint size) => size < 0;tx0 reports: size < 0 is always false, as the uint is never negative bool Fine(int size) => size < 0; void Check(ulong n) { if (n >= 0)tx0 reports: n >= 0 is always true, as the ulong is never negative { } }} 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:
[rules]
"tx0/csharp:unsigned-sign-test" = "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:unsigned-sign-test] reason="..."tx0 explain tx0/csharp:unsigned-sign-test shows the same in the terminal. Found a false positive? Report it.