Bug 17677 - Can't compare byte array using Comparer
Summary: Can't compare byte array using Comparer
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-02-10 03:27 UTC by Ryoji.Ishikawa
Modified: 2014-02-13 17:47 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Ryoji.Ishikawa 2014-02-10 03:27:39 UTC
Though the following sample code work in .NET v4.5, in Xamarin.iOS it has an exception.
I'm using,
 Xamarin.iOS: 7.0.6.128(Business Edition)
 Xcode: 5.0.2(3335.32)
 Xamarin Studio: 4.2.2(build2)

----------------------------------------------------------------------------
using System;
using System.Collections.Generic;


byte[] v1 = new byte[]{0,1};
byte[] v2 = new byte[]{2,3};

int ret = Comparer<object>.Default.Compare(v1, v2);  // does not implement right interface
----------------------------------------------------------------------------

Is it bug?
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-02-10 09:33:12 UTC
This fails using the desktop mono too:

$ csharp
csharp> using System;
csharp> using System.Collections.Generic;
csharp>  
csharp> byte[] v1 = new byte[]{0,1};
csharp> byte[] v2 = new byte[]{2,3};
csharp>  
csharp> int ret = Comparer<object>.Default.Compare(v1, v2);
System.ArgumentException: does not implement right interface
  at System.Collections.Generic.Comparer`1+DefaultComparer[System.Object].Compare (System.Object x, System.Object y) [0x00000] in <filename unknown>:0 
  at <InteractiveExpressionClass>.Host (System.Object& $retval) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) [0x00000] in <filename unknown>:0 
  at Mono.CSharpShell.Evaluate (System.String input) [0x00000] in <filename unknown>:0 
csharp>
Comment 2 Marek Safar 2014-02-10 09:46:38 UTC
Attached code fails on .NET 4.5 with same exception
Comment 3 Ryoji.Ishikawa 2014-02-11 20:15:01 UTC
I have updated sample code.

----------------------------------------------------------------------------
using System;
using System.Collections.Generic;


byte[] v1 = new byte[]{0,1};

int ret = Comparer<object>.Default.Compare(v1, v1);  // does not implement
right interface
----------------------------------------------------------------------------
Comment 4 Marek Safar 2014-02-12 02:32:16 UTC
This case works with mono master as well (fixed last week)