> While the implementation is close to what you describe, that > really isn't relevant.
I guess I'm a pragmatist, in that I feel like shipped implementations are more relevant than specs. :P Seriously, nice catch. I agree, it does sound like a bug. It'll be interesting to see if this bug gets fixed... the workaround is pretty trivial. I think the ability to instantiate, and call interface methods on, non-public valuetypes sounds like a far more serious find... MS should start paying you, Jeroen. Cheers, -Shawn http://www.windojitsu.com/ -----Original Message----- From: Jeroen Frijters [mailto:[EMAIL PROTECTED] Sent: Sunday, May 16, 2004 01:17 Subject: Re: Visibility of an array type and the element type I disagree. While the implementation is close to what you describe, that really isn't relevant. In the type system, there really are distinct types for each array type. I would argue that the behavior described by the original poster is in fact a bug. The spec says (part. I 8.5.3.1 Visibility Of Type): "The visibility of a type definer is the same as that for the type from which it was generated." (as I understand it, an array type is a "type definer") It did some experimenting and it appears that handling of visibility is completely broken in the CLR. In IL it is possible to declare local variables of non-visible types, instantiate arrays and possibly lots of other things. For reference types, this isn't too bad, because you can't do anything useful with a null reference, but for value types this could be dangerous. It's trivial to create an instance of a value type that is private to mscorlib and once you box it, you can call the System.Object methods on it (or any methods on public interfaces it might implement). Regards, Jeroen > -----Original Message----- > From: Unmoderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of > Shawn A. Van Ness > Sent: Sunday, May 16, 2004 06:40 > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Visibility of an array type > and the element type > > At run-time, there is no such type as "SomeClass[]". There is only > System.Array -- and that type is, indeed, public. > > System.Array is a special type, in that it has what they call > "element type" > -- meaning that it's a type composed of (or referring to) > some other type > (in this case, SomeClass). > > Make sense? > > Cheers, > -Shawn > http://www.windojitsu.com/ > > > -----Original Message----- > From: Dmitry Shaporenkov [mailto:[EMAIL PROTECTED] > Sent: Saturday, May 15, 2004 04:02 > Subject: Visibility of an array type and the element type > > Hi all, > > the output of the following program is a mystery for me: > > > using System; > > internal class SomeClass {} > > public class ReflectionTest > { > public static void Main () > { > SomeClass [] sc = new SomeClass [0]; > Console.WriteLine (sc.GetType().IsPublic); // True ??? > Console.WriteLine (sc.GetType().GetElementType ().IsPublic); // > False - OK > } > } > > > It seems that via Reflection I get that the array type SomeClass[] has > public visibility. I would expect it to have > the same visibility as its element type. Any ideas how this > can happen? > > > Regards, > Dmitry Shaporenkov > > =================================== > This list is hosted by DevelopMentor- http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== > This list is hosted by DevelopMentor+ http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > > =================================== This list is hosted by DevelopMentor. http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com