[Mono-list] mcs scope protection bug?
daniel@solin.org
daniel@solin.org
Tue, 21 Jan 2003 22:35:34 -0800
Greetings everybody,
According to ECMA-334, as well as the MS docs, using C#'s 'internal'
keyword on a class should result in that class only being accessible
from the class' own assembly. Right?
Now, consider the following example:
[myclass.cs]
namespace MyNamespace
{
internal class MyClass
{
}
public class MyOtherClass
{
public static void Main(string[] args)
{
MyClass mc = new MyClass();
}
}
}
Compiling and running this alone should cause no problem:
daniel@localhost:~$ mcs myclass.cs
Compilation succeeded
daniel@localhost:~$ mono myclass.exe
daniel@localhost:~$
Okay, so far so good. But, if I now compile myclass.cs into a dll:
daniel@localhost:~$ mcs /t:library myclass.cs
Compilation succeeded
And then write another source file that tries to use MyClass from the
MyNameSpace namespace:
[usingmynamespace.cs]
using MyNamespace;
class UsingMyClass
{
public static void Main(string[] args)
{
MyClass mc = new MyClass();
//do something with mc
}
}
Compiling this, if I understood it correctly, should result in an error.
The problem is that it don't:
daniel@localhost:~$ mcs /r:./myclass.dll usingmyclass.cs
Compilation succeeded
If I, on the other hand, try to do the same with the MS compiler, I get
the following:
C:\temp>csc /r:./myclass.dll usingmyclass.cs
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.
usingmyclass.cs(7,13): error CS0122: 'MyNamespace.MyClass' is inaccessible due to its protection level
Question is: Is this a bug, an unimplemented feature, or am I just being
ignorant? :-)
Thanks,
Dan