[Mono-bugs] [Bug 345907] New: Incompatibility with .NET 2.0

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Dec 4 10:28:06 EST 2007


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


           Summary: Incompatibility with .NET 2.0
           Product: Mono: Class Libraries
           Version: 1.2.6
          Platform: x86
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: rolandasr at gmail.com
         QAContact: mono-bugs at ximian.com
          Found By: ---


Description of Problem:
Non-compilable code in version 1.2.6

Steps to reproduce the problem:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;

namespace ConsoleApplication1
{
    public delegate T ReaderHandler<T>(IDataReader reader);
    public delegate T CommandHandler<T>(IDbCommand cmd);

    class Program
    {
        static void Main(string[] args)
        {
        }

        public static T ExecuteCommand<T>(IDbCommand cmd, CommandHandler<T>
handler)
        {
            try
            {
                if (cmd.Connection == null)
                {
                    using (IDbConnection conn = new SqlConnection())
                    {
                        cmd.Connection = conn;
                        return handler(cmd);
                    }
                }
                else
                {
                    return handler(cmd);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static T ExecuteCommand<T>(IDbCommand cmd, CommandHandler<T>
handler,
                                          bool isCommitable)
        {
            return ExecuteCommand<T>(cmd, handler);
        }

        public static T ExecuteReader<T>(IDbCommand cmd, ReaderHandler<T>
handler)
        {
            return ExecuteCommand<T>(cmd,
                                     delegate(IDbCommand liveCommand)
                                     {
                                         IDataReader r =
liveCommand.ExecuteReader();
                                         return handler(r);
                                     });
        }
    }
}

Actual Results:

Error CS0029: Cannot implicitly convert type `T' to `T'
Error CS1662: Cannot convert `anonymous method' to delegate type
`ConsoleApplication1.CommandHandler<T>' because some of the return types in the
block are not implicitly convertible to the delegate return type

Expected Results:
In .NET 2.0 the code compiles without any problem.


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