Skip to content

Commit 385dd0e

Browse files
authored
Fix predicate nullability annotation (#7176)
2 parents e2be4d3 + 5aad53c commit 385dd0e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/TestFramework/TestFramework/Assertions/Assert.Contains.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public static T ContainsSingle<T>(Func<T, bool> predicate, IEnumerable<T> collec
192192
/// Users shouldn't pass a value for this parameter.
193193
/// </param>
194194
/// <returns>The item that matches the predicate.</returns>
195-
public static object? ContainsSingle(Func<object, bool> predicate, IEnumerable collection, string? message = "", [CallerArgumentExpression(nameof(predicate))] string predicateExpression = "", [CallerArgumentExpression(nameof(collection))] string collectionExpression = "")
195+
public static object? ContainsSingle(Func<object?, bool> predicate, IEnumerable collection, string? message = "", [CallerArgumentExpression(nameof(predicate))] string predicateExpression = "", [CallerArgumentExpression(nameof(collection))] string collectionExpression = "")
196196
{
197197
object? firstMatch = null;
198198
int matchCount = 0;

src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertGenericIsExactInstance
4343
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertGenericIsNotExactInstanceOfTypeInterpolatedStringHandler<TArg>
4444
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsExactInstanceOfTypeInterpolatedStringHandler
4545
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsNotExactInstanceOfTypeInterpolatedStringHandler
46+
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ContainsSingle(System.Func<object?, bool>! predicate, System.Collections.IEnumerable! collection, string? message = "", string! predicateExpression = "", string! collectionExpression = "") -> object?
4647
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsExactInstanceOfType(object? value, System.Type? expectedType, string? message = "", string! valueExpression = "") -> void
4748
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsExactInstanceOfType(object? value, System.Type? expectedType, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertIsExactInstanceOfTypeInterpolatedStringHandler message, string! valueExpression = "") -> void
4849
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsExactInstanceOfType<T>(object? value, string? message = "", string! valueExpression = "") -> T
@@ -52,4 +53,3 @@ static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotExactInstanceOfT
5253
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotExactInstanceOfType<T>(object? value, string? message = "", string! valueExpression = "") -> void
5354
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotExactInstanceOfType<T>(object? value, ref Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AssertGenericIsNotExactInstanceOfTypeInterpolatedStringHandler<T> message, string! valueExpression = "") -> void
5455
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ContainsSingle(System.Collections.IEnumerable! collection, string? message = "", string! collectionExpression = "") -> object?
55-
static Microsoft.VisualStudio.TestTools.UnitTesting.Assert.ContainsSingle(System.Func<object!, bool>! predicate, System.Collections.IEnumerable! collection, string? message = "", string! predicateExpression = "", string! collectionExpression = "") -> object?

test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.Contains.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ public void ContainsSinglePredicate_InNonGenericCollection_NoMessage_OneItemMatc
14191419
var collection = new ArrayList { 1, 2, 3, 4, 5, "a" };
14201420

14211421
// Act
1422-
object? result = Assert.ContainsSingle(x => x.Equals(3), collection);
1422+
object? result = Assert.ContainsSingle(x => x!.Equals(3), collection);
14231423

14241424
// Assert
14251425
result.Should().Be(3);

0 commit comments

Comments
 (0)