[Mono-dev] Event handler assigment possible bug?

Sunny sloncho at gmail.com
Fri Sep 16 17:30:31 EDT 2005


Hi,
I searched in bugzilla, but I did not find an entry for that. I could
not find it discussed in the list as well. It always depends on the
keywords used, so I may omit some results though.

Anyway, the following code compiles OK with mono 1.1.9 on SuSE 9.3,
but it fails to compile under .Net, and according the ECMA C# spec,
possition 8.7.5. (Events), .Net behaviour is the right one, i.e. this
code should fail to compile.

If this is a bug, and it is not yet put in bugzilla, do you want me to
put it in?

Here is the code:

using System;

namespace test
{
public delegate void MyHandlerDelegate(object o, EventArgs e);

class MainClass
{
        public static void Main(string[] args)
        {
                Console.WriteLine("Hello World!");

                TestClassBase test = new TestClassBase();

               //This line fails under .Net, as according the
               //ECMA specs (8.7.5):
               //"An instance of a delegate type encapsulates 
               //one or more callable entities."

               test.MyEvent += MyHandler;
        }

        static void MyHandler (object o, EventArgs e)
        {
        }
}

class TestClassBase
{
        public string T1;

        public event MyHandlerDelegate MyEvent;
}


}

Cheers
and have a nice weekend.

--
Svetoslav Milenov (Sunny)



More information about the Mono-devel-list mailing list