[Mono-bugs] [Bug 706881] New: gmcs supports extension 'Add' method to be used for collection initialization syntax, differs from csc

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jul 19 19:42:41 EDT 2011


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

https://bugzilla.novell.com/show_bug.cgi?id=706881#c0


           Summary: gmcs supports extension 'Add' method to be used for
                    collection initialization syntax, differs from csc
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.10.x
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: michael.miller at suse.com
        ReportedBy: aaron.bockover+novell at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


This may (and I hope is) a Microsoft C# compiler (csc) bug, but I have
confirmed different behavior between gmcs and csc. I ran into this in
production, which led to a broken build on Windows.

If an object has an Add method and implements IEnumerable, the C# collection
initializer syntax may be used to add items to the object via its Add method.

If an object does not have an Add method, through gmcs it is possible to take
advantage of collection initializer syntax by providing the Add method as an
extension method. However, this is not allowed in csc.

gmcs appears to resolve extension methods before it handles collection
initializer syntax, whereas csc resolves extension methods later/after
collection initializer syntax handling.

I have no idea which compiler is wrong, but they do differ. I've tried 3.5 and
4.0 csc versions and gmcs 2.10.

-- 
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