Question about compiler error with nested classes

  • Thread starter Thread starter Luis Diego Fallas
  • Start date Start date
L

Luis Diego Fallas

Hi everyone ,

I'm having a problem when trying to compile code that contains the
following pattern:

using System;

public class A {

public class B : Inn.C { }

....

public class Inn {

public interface I { }

....

public class C : I { }

public class D { }


}

....

public static void Main(String[] a) { }

}

I know that changing the order of the class definitions can be used as a
workaround. But if "class B" and "class Inn" are defined in separate files
the problem is reproduced.

Is there a service pack for csc?

Anyone knows something about this problem?


Thanks in advance.
 
This is a known bug in the C# compiler. As far as I know, there is no
service pack that fixes this, but is fixed in our current builds. When the
classes are in different files, the compiler still processes them according
to the order that they are given. So if you're building using csc.exe, you
can achieve the same affect my re-ordering the source files on the
command-line. I'm not sure the IDE exposes a way to do this, but I would
try (as a last resort) manualyl changing the ordering of the source files
in the .csproj file.
 
Thanks for the information.

Question, is there a different scenario for this bug? The bug is only
related to inheritance and nested classes/interfaces? I tell you this
because I'm generating C# code.

Thanks again.
 
From: "Luis Diego Fallas said:
Subject: Re: Question about compiler error with nested classes

Thanks for the information.

Question, is there a different scenario for this bug? The bug is only
related to inheritance and nested classes/interfaces? I tell you this
because I'm generating C# code.

Nope that's the basic repro: combining nesting with inheritance. My
personal recommendation: don't generate so many nested interfaces/classes.
 
Back
Top