Search Issue Tracker
By Design
Votes
0
Found in
2018.3.5f1
Issue ID
1139185
Regression
Yes
Array.BinarySearch parameters get swapped from .NET 3.4 to .NET 4.0
Binary search gives different ordering of IComparer parameters
In my array of y's, I will search for element "x", when executing Array.BinarySearch<string>(yArray, x, m_stringComparer);
- In .net 3.5, for the exact same code, i get X=X and Y=Y
- In .net 4.0 I get: X=Y and Y=X
This completely broke the main word search game mechanic of a customer project that's i've been using for upgrade testing.
To repro this:
1. download this project
2. Open it with Unity 18.3 --> 19.2
3. Enter Play Mode and press SPACE
4. The project is submitted with .NET 3.5 and it will print : X=X and Y=Y
5. Change to .NET 4.0 and repeat
6. Notice it will now print: X=Y and Y=X
Reproduced with: 2017.4.3f1, 2018.3.9f1, 2019.1.0b8, 2019.2.0a10 (trunk) --> when switching to .NET 4.0
Cannot reproduce with all of the above if .NET is 3.5
In 2019.2, .NET 3.5 is not even an option anymore so the upgraded project just breaks without a workaround (besides changing the code)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Only one out of multiple cameras is shown in the Play Mode while HDR display is used and Direct3D12 is set as the graphics API
- The "Paste Component as New" option is incorrectly displayed as active despite the action being prohibited
- "TLS Allocator ALLOC_TEMP_TLS" errors are thrown when unsuccessfully importing an FBX file
- A memory leak occurs in Play mode when using Direct3D12 Graphics API
- Crash on GfxDeviceD3D12Base::DrawBuffersCommon when rendering 60 real-time lights in the far distance
Resolution Note:
The IComparer<T> implementation is relying on order of parameters being passed in. It needs to correctly compare parameters not matter the order.