You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the test class below, the analyzer fires on Assert.IsTrue(dict.Contains("a")), and the auto-fix modifies the behaviour of the test so it no longer passes.
This is because Dictionary.Contains seems to have different semantics from Dictionary<K,V>.Contains
[TestClass]publicclassMSTEST0037{
#pragma warning disable MSTEST0037// Use proper 'Assert' methods[TestMethod]publicvoidExample1_DictionaryCount(){vardict=CreateStringStringDictionaryTypedAsNonGeneric();Assert.IsTrue(dict.Contains("a"),"Expected dictionary to contain key 'a'");}
#pragma warning restore MSTEST0037// Use proper 'Assert' methods/// <summary>/// This is the the result of applying MSTest0037 auto-fix to test <see cref="Example1_DictionaryCount"/>/// It makes the test fail./// </summary>[TestMethod]publicvoidExample1_DictionaryCount_FixedByMsTest0037(){vardict=CreateStringStringDictionaryTypedAsNonGeneric();Assert.Contains("a",dict,"Expected dictionary to contain key 'a'");}privatestaticIDictionaryCreateStringStringDictionaryTypedAsNonGeneric()=>newDictionary<string,string>(){{"a","b"}};}
Activity