[Mono-list] MCS can't handle private access scope?

daniel@solin.org daniel@solin.org
Wed, 22 Jan 2003 23:16:34 -0800


Hi again,

Think I found another access-scope-related bug. Please take a look
at the following:

1. Create calculator.cs:
namespace Calculator
{
    class MyCalculator
    {
        private Validator va = new Validator();

        public int add(int val1, int val2)
        {
            if(va.validate(val1) && va.validate(val2))
                return (val1+val2);
            else
                return 0;
        }

        private class Validator
        {
            public bool validate(int val)
            {
                if(val<0)
                    return false;
                else
                    return true;
            }
        }
    }
}

2. Compilte calculator.cs into a dll:
daniel@localhost:~$ mcs /t:library calculator.cs

3. Create myclass.cs:
using System;
using Calculator;

class MyClass
{
    public static void Main(string[] args)
    {
        MyCalculator.Validator v = new MyCalculator.Validator();
    }
}

4. Compile myclass.cs:
daniel@localhost:~$ mcs /r:./calculator.dll myclass.cs

5. This compiles fine, but since we're trying to access the private
class Validator from myclass.cs, I think this should generate an error.
The MS compiler gives me the following:

C:\temp>csc /r:./calculator.dll myclass.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.

myclass.cs(8,9): error CS0122: 'Calculator.MyCalculator' is inaccessible due to its protection level


Shall I do a bugzilla about this?

Thx,
Dan