A public generic type declares a public static method, which callers must call with type arguments
What it finds
A static method of Cache<T> has to be called as Cache<string>.Clear(): the type arguments cannot be inferred from the call. A static method on a non-generic class, or a generic method, is easier to use. Operators and methods of interfaces are left alone.
From the rule's source, static_member_of_generic_type.rs.
public class Cache<T>{ public static void Clear() { }tx0 reports: Clear is static in the generic type Cache public void Add(T item) { }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:static-member-of-generic-type" = "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:static-member-of-generic-type] reason="..."tx0 explain tx0/csharp:static-member-of-generic-type shows the same in the terminal. Found a false positive? Report it.