Skip to content

Fix MSTEST0037 incorrectly rewriting non-generic IDictionary.Contains by @Evangelink in #9968 (backport to rel/4.3) - #9979

Merged
Amaury Levé (Evangelink) merged 2 commits into
microsoft:rel/4.3from
nohwnd-bot:backport/9968/to/rel/4.3
Jul 15, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
microsoft:rel/4.3from
nohwnd-bot:backport/9968/to/rel/4.3

Conversation

@nohwnd-bot

Copy link
Copy Markdown
Contributor

Backport of #9968 to rel/4.3

/cc Amaury Levé (@Evangelink)

Non-generic System.Collections.IDictionary.Contains(object) checks for a matching key, whereas Assert.Contains enumerates the dictionary (yielding DictionaryEntry items). The two are not equivalent, so the code fix silently changed test behavior. The analyzer now skips the Contains-to-Assert.Contains suggestion when the invoked Contains is IDictionary.Contains (or an implementation of it, e.g. Hashtable).

Fixes microsoft#9966
…ionary check

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 2fa4d247-7176-4fac-8687-c53ae849933a
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) July 15, 2026 15:14
@Evangelink
Amaury Levé (Evangelink) merged commit 509cbe9 into microsoft:rel/4.3 Jul 15, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants