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
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
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Red spots appear when Blending Lighting Scenarios using Adaptive Probe Volumes
- [Windows] About Unity Window needs to be opened twice to adapt to resolution
- NullReferenceException and temporary graph corruption after entering playmode if output node connection was changed
- Sprite Renderer with Animation does not reflect Sprite changes in the Scene when switching Mask Interaction
- User is redirected to a non-existing online documentation link when clicking on "?" help button inside Inspector window while Animator Override Controller is selected
Add comment