For example:
public class A : A.B
{
public class B { }
}
Which generates this error from the compiler:
Circular
I was able to avoid this (at least with interfaces) by inheriting from a separate class containing the nested interfaces. (In my scenario I am also returning references to these interfaces.)
Instead of:
public class MyClass :
MyClass.Interface
where T1 : ...
where T2 : ...
where T3 : ... {
public interface Interface { Interface SomeMethod(); }
Interface Interface.SomeMethod() {
...
}
}
// compile error: Circular base class dependency
Do something like this:
public sealed class MyClassInterfaces
where T1 : ...
where T2 : ...
where T3 : ... {
public interface Interface { Interface SomeMethod(); }
}
sealed class MyClass :
MyClassInterfaces.Interface
where T1 : ...
where T2 : ...
where T3 : ... {
MyClassInterfaces.Interface
MyClassInterfaces.Interface.SomeMethod() {
...
}
}
To avoid the ugliness with explicit interface implementations, you can also inherit from the other class, though that wouldn't work if you were trying to inherit from a nested class, since you can't inherit from both classes.
public abstract class MyClassInterfaces
where T1 : ...
where T2 : ...
where T3 : ... {
public interface Interface { Interface SomeMethod(); }
}
sealed class MyClass :
MyClassInterfaces,
MyClassInterfaces.Interface
where T1 : ...
where T2 : ...
where T3 : ... {
Interface Interface.SomeMethod() {
...
}
}