[Mono-bugs] [Bug 375966] New: Compiler gets confused when passing a generic method to a delegate

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 1 12:43:53 EDT 2008


           Summary: Compiler gets confused when passing a generic method to
                    a delegate
           Product: Mono: Compilers
           Version: 1.9.0
          Platform: i686
        OS/Version: openSUSE 10.3
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: sontek at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

This works on MS.NET, Here is the compile error:

sontek at inspidel:/data/code/tests> gmcs mono-generics3.cs 
mono-generics3.cs(21,38): error CS0123: A method or delegate
`BaseFactory.InitializeDataObject(DataObject, string, int)' parameters do not
match delegate `InitializeHelper<T>.PerformInitializeCallback(in T, string,
int)' parameters
mono-generics3.cs(7,26): (Location of the symbol related to previous error)
mono-generics3.cs(27,20): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings

small code example:

using System;
using System.Collections.Generic;

internal class InitializeHelper<T> where T : DataObject, new()
    public delegate void PerformInitializeCallback(T t, string attr, int
    public InitializeHelper(PerformInitializeCallback perform, string attr)

public abstract class DataObject
   public DataObject() { } 
public class MsSqlDataObjectFactory : BaseFactory
    T[] ExecuteReaderAndGetObjects<T>(int command, string attr) where T :
DataObject, new()
        InitializeHelper<T> helper = new
InitializeHelper<T>(InitializeDataObject, attr);
        return new T[] { };
public abstract class BaseFactory
    protected void InitializeDataObject(DataObject ob, string attr, int reader)

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