[Mono-bugs] [Bug 440776] New: cannot resolve complex set of generic methods

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Oct 31 18:36:17 EDT 2008


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


           Summary: cannot resolve complex set of generic methods
           Product: Mono: Compilers
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: wasabi at larvalstage.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


You'll notice the number of Try methods in this class is pretty complex. I get
the following errors.

66: The call is ambiguous between the following methods or properties:
`ISIS.Util.ExceptionHandler.Try(System.Action)' and
`ISIS.Util.ExceptionHandler.Try<void>(System.Func<void>)'(CS0121)]

71: Cannot implicitly convert type `void' to `R'(CS0029)]

76: The call is ambiguous between the following methods or properties:
`ISIS.Util.ExceptionHandler.Try(System.Action)' and
`ISIS.Util.ExceptionHandler.Try<void>(System.Func<void>)'(CS0121)]

81: Cannot implicitly convert type `void' to `R'(CS0029)]

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

namespace ISIS.Util
{

    /// <summary>
    /// Base class of classes capable of handling exceptions.
    /// </summary>
    public abstract class ExceptionHandler
    {

        /// <summary>
        /// Handles the exception.
        /// </summary>
        /// <param name="e"></param>
        public abstract void Handle(Exception e);

        /// <summary>
        /// Attempts to do the action, handling the exception.
        /// </summary>
        /// <param name="action"></param>
        public void Try(Action action)
        {
            try
            {
                action();
            }
            catch (Exception e)
            {
                try
                {
                    Handle(e);
                }
                catch
                {
                    throw e;
                }
            }
        }

        public R Try<R>(Func<R> func)
        {
            try
            {
                return func();
            }
            catch (Exception e)
            {
                try
                {
                    Handle(e);
                    return default(R);
                }
                catch
                {
                    throw e;
                }
            }
        }

        public void Try<T>(Action<T> action, T t)
        {
            Try(() => action(t));
        }

        public R Try<R, T1>(Func<T1, R> func, T1 t1)
        {
            return Try(() => func(t1));
        }

        public void Try<T1, T2>(Action<T1, T2> action, T1 t1, T2 t2)
        {
            Try(() => action(t1, t2));
        }

        public R Try<R, T1, T2>(Func<T1, T2, R> func, T1 t1, T2 t2)
        {
            return Try(() => func(t1, t2));
        }

    }

}


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