Keys.Contains or Values.Contains is called on a dictionary, where ContainsKey or ContainsValue says it directly
What it finds
map.Keys.Contains(k) may go through LINQ on the key collection; map.ContainsKey(k) is the direct lookup. For values, ContainsValue avoids the same detour.
From the rule's source, keys_contains.rs.
using System.Collections.Generic; class Lookup{ bool Has(Dictionary<string, int> map, string key) => map.Keys.Contains(key);tx0 reports: this lookup reads better as ContainsKey} 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:keys-contains" = "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:keys-contains] reason="..."tx0 explain tx0/csharp:keys-contains shows the same in the terminal. Found a false positive? Report it.