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
- Trail Renderer visual doesn't match the positions of vertices when they have been offset
- [Mobile] The Material is not visible when using the Decal Renderer Feature
- Uncaught TypeError: Cannot read properties of undefined is thrown when the tab is inactive for several minutes
- Crash on mono_array_length when building a project
- "StackOverflowException" error when changing spline curve type from "Bezier" to "Auto" in the "Element Inspector"
Add comment