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
Dictionary<string,string>dictionary= ...Assert.IsTrue(dictionary.TryGetValue(key,outvarvalue));Assert.AreEqual(5,value.Length);// should know that value is not null, but still warns currently
similarly:
Dictionary<string,string>dictionary= ...var found =dictionary.TryGetValue(key,outvarvalue);if(!found)Assert.Fail();Assert.AreEqual(5,value.Length);// should know that value is not null, but still warns currently
Expected behavior
No compiler warnings.
Actual behavior
Compiler warnings issued on value.Length.
Environment
Using version 2.2.7 of MSTest.TestAdapater and MSTest.TestFramework
The work is already done to add the conditionally included compiler attributes in NullableAttributes.cs, so there shouldn't be too much to add here. So if this looks like an acceptable proposal I can put in a PR for it!
Description
Following #714
and borrowing from https://devblogs.microsoft.com/dotnet/try-out-nullable-reference-types/#flow-attributes-doesnotreturn-and-doesnotreturnifbool
Can
DoesNotReturnIf
be added toAssert.IsTrue
/Assert.IsFalse
? AndDoesNotReturn
be added toAssert.Fail()
? There are some other null checks should be able to be skipped, such as:Steps to reproduce
similarly:
Expected behavior
No compiler warnings.
Actual behavior
Compiler warnings issued on
value.Length
.Environment
Using version
2.2.7
of MSTest.TestAdapater and MSTest.TestFrameworkWorkaround
Similar shims can be written such as
The text was updated successfully, but these errors were encountered: