Code Inspection: Possible infinite inheritance
In a situation similar to the following:
class B<U>
{
}
class A<T> : B<A<A<T>>>
{
}
You effectively end up with the type A<T>
that inherits an infinitely recursive type B
. As a result, your assembly will compile, but you will be unable to execute it. If you try, you will get an error message similar to the following:
Could not load type ‘ConsoleApplication1.A{{1' from assembly 'ConsoleApplication1, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' because it has recursive generic definition.
Last modified: 21 March 2024