Search Issue Tracker

Won't Fix

Votes

0

Found in

2017.3.1f1

Issue ID

1008619

Regression

No

IEnumerable<T>.Contains(null) returns False when Array has a null object in .NET 3.5

Mono

-

Steps to reproduce:
1. Open attached “ContainsNull.zip” Unity project
2. Open “Default” scene
3. Enter Play mode
4. Observe Console window

Expected results:
array.Contains(null) returns True
Actual results:
array.Contains(null) returns False even though a null object is present the array

Reproduced in: 2018.2.0a3, 2018.1.0b10, 2017.3.1p3, 2017.2.2f1, 2017.1.3p2, 2017.1.0a1

Note: works as expected in .NET 4.6

==========

Hello,

A workaround is to pass EqualityComparer<object>.Default when making the call to contains, i.e.

Console.WriteLine("array.Contains(null):" + array.Contains(null, EqualityComparer<object>.Default));

A change in behavior like this is risky to make to the legacy mono runtime. Given that there is a workaround and this works correctly in the new Mono I don't intend to make a fix to the legacy Mono.

Thanks,
Jonathan

Add comment

Log in to post comment