[Mono-bugs] [Bug 429264] New: TypeLoadException with IEnumerable<IEnumerable<T>>

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Sep 23 14:46:10 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=429264


           Summary: TypeLoadException with IEnumerable<IEnumerable<T>>
           Product: Mono: Class Libraries
           Version: SVN
          Platform: x86-64
        OS/Version: openSUSE 11.0
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Core
        AssignedTo: jbevain at novell.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


This probably isn't a class library problem, but I'm not sure where the problem
is, either...

Save the following source:

  using System;
  using System.Collections.Generic;
  using System.Linq;

  public static class RectangularArrayRocks
  {
    public static IEnumerable<IEnumerable<TSource>> Rows<TSource> (this
TSource[,] self)
    {
      int rows = self.GetLength (0);
      int cols = self.GetLength (1);

      return CreateRowsIterator (self, rows, cols);
    }

    private static IEnumerable<IEnumerable<TSource>>
CreateRowsIterator<TSource> (TSource[,] self, int rows, int cols)
    {
      for (int i = 0; i < rows; ++i)
        yield return CreateColumnIterator (self, i, cols);
    }

    private static IEnumerable<TSource> CreateColumnIterator<TSource>
(TSource[,] self, int i, int cols)
    {
      for (int j = 0; j < cols; ++j)
        yield return self [i, j];
    }
  }


  class Test {
    public static void Main ()
    {
      int[,] s = new int[,] {
        {1, 2, 3},
      };
      IEnumerable<IEnumerable<int>> r = s.Rows();
      Console.WriteLine (new[]{1,2,3}.SequenceEqual (r.ElementAt (0)));
    }
  }

Compile it:

  gmcs f.cs

Run it:

  mono --debug f.exe

Expected output:

  True

Actual output:

Unhandled Exception: System.TypeLoadException: A type load exception has
occurred.
  at System.Linq.Enumerable.SequenceEqual[Int32] (IEnumerable`1 first,
IEnumerable`1 second, IEqualityComparer`1 comparer) [0x00027] in
/home/jon/Development/mono-HEAD/mcs/class/System.Core/System.Linq/Enumerable.cs:2256 
  at System.Linq.Enumerable.SequenceEqual[Int32] (IEnumerable`1 first,
IEnumerable`1 second) [0x00000] in
/home/jon/Development/mono-HEAD/mcs/class/System.Core/System.Linq/Enumerable.cs:2242 
  at Test.Main () [0x00000] 

This is obviously somewhat bogus, as Enumerable.cs:2256 is:

  if (!second_enumerator.MoveNext ())

implying that the .MoveNext() call is throwing the TypeLoadException.

What type?  No idea.

NET generates "True", as expected.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list