Infinite recursion (CA2011)
Esta página aún no está disponible en tu idioma.
Key dotnet.codequality.infinite-recursion · Severity critical · Category codequality
Microsoft analyzer CA2011. Flags a property setter that assigns the property itself, which recurses until the process dies with a stack overflow. A getter that reads itself and a method that calls itself are reported by Unconditional recursion (ARCH717).
Incorrect
Section titled “Incorrect”public string Name{ get => _name; set => Name = value; // assigns itself}Correct
Section titled “Correct”private string _name = "";
public string Name{ get => _name; set => _name = value;}