[Mono-devel-list] Null Attributes arguments

Kelly Leahy kellyleahy at swbell.net
Thu Dec 9 10:43:52 EST 2004


--- Marek Safar <marek.safar at seznam.cz> wrote:

> 
> > using System;
> 
> [X (null)]
> class X : Attribute {
> 	int ID;
> 	public X () {}
>         public X (object o) { ID = 55; }
> 	
>         static int Main ()
> 	{
> 	    object[] attrs =
> typeof(X).GetCustomAttributes(typeof (X),false);
> 	    if (attrs.Length != 1)
> 		return 2;
> 	    
> 	    X x = attrs [0] as X;
> 	    if (x.ID != 55)
> 		return 2;
> 	    
> 	    Console.WriteLine("OK");
> 	    return 0;
> 	}
> }

What is the value of the argument ("object o") passed
to the constructor of X in this case by the compiler? 
Is it *null* or something else?

Shouldn't the test check that it is what is expected
as well, and of the correct type?

Kelly



More information about the Mono-devel-list mailing list