JetBrains Rider 2024.1 Help

Code Inspection: Possible infinite inheritance

Category

Potential Code Quality Issues

ID

PossibleInfiniteInheritance

EditorConfig

resharper_possible_infinite_inheritance_highlighting

Default severity

Warning

Language

C#, VB.NET

Requires SWA

No

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: 17 April 2024