[Mono-bugs] [Bug 484174] New: gmcs does not check missing IEnumerable.GetEnumerator() for IList<T> implementation

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Mar 11 03:15:50 EDT 2009


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


           Summary: gmcs does not check missing
                    IEnumerable.GetEnumerator() for IList<T>
                    implementation
    Classification: Mono
           Product: Mono: Compilers
           Version: SVN
          Platform: i586
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: atsushi at ximian.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.7)
Gecko/2009021910 Firefox/3.0.7 GTB5 (.NET CLR 3.5.30729)

In the sample code below, it implements generic IList, which implements both
IEnumerable and IEnumerable<T> (through ICollection<T>).

It lacks IEnumerable.GetEnumerator() (of non-generic IEnumerable) so it should
not compile, but it actually does. And it causes run-time crash.

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml;

public class MyList : IList<string>
{
    public void Clear () {}
    public void Add(string s) {}
    public void Insert(int idx, string s) {}
    public bool Contains(string s) { return false; }
    public IEnumerator<string> GetEnumerator () { yield break; }
    public bool Remove(string s) { return false; }
    public void RemoveAt(int i) {}
    public void CopyTo (string [] arr, int index) {}
    public int IndexOf (string s) { return -1; }

    public int Count { get { return 0; } }
    public bool IsReadOnly { get { return false; } }
    public string this [int index] { get { return null; } set { } }
}


Reproducible: Always

Steps to Reproduce:
explained above.
Actual Results:  
no CS0536.

Expected Results:  
CS0536, report lack of GetEnumerator. (right now I have useless japanese
langpack so I don't paste the msg here :( )

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


More information about the mono-bugs mailing list