From 38f1aa1d5b4bc0984baf1903a2027224f0087eed Mon Sep 17 00:00:00 2001 From: Alexander Gayko Date: Wed, 14 Jan 2026 13:54:39 +0100 Subject: [PATCH] make it more obvious that this is about local functions ... by sorrounding the fibonacci function/lambda with a proper method. ... also, unified spacing around operators --- .../code-analysis/style-rules/ide0039.md | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0039.md b/docs/fundamentals/code-analysis/style-rules/ide0039.md index 19e4225527fb8..e2babe190576d 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0039.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0039.md @@ -42,17 +42,28 @@ Options specify the behavior that you want the rule to enforce. For information | **Default option value** | `true` | | ```csharp -// csharp_style_prefer_local_over_anonymous_function = true -int fibonacci(int n) +int CalcFib5() { - return n <= 1 ? 1 : fibonacci(n-1) + fibonacci(n-2); + // csharp_style_prefer_local_over_anonymous_function = true + int fibonacci(int n) + { + return n <= 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2); + } + return fibonacci(5); } -// csharp_style_prefer_local_over_anonymous_function = false -Func fibonacci = (int n) => +// vs. + +int CalcFib5() { - return n <= 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2); -}; + // csharp_style_prefer_local_over_anonymous_function = false + Func fibonacci = (int n) => + { + return n <= 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2); + }; + + return fibonacci(5); +} ``` ## Suppress a warning