Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions docs/fundamentals/code-analysis/style-rules/ide0039.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name should use PascalCase according to .NET naming conventions. Consider renaming to "CalculateFib5" or "GetFibonacci5" to follow standard .NET naming conventions for public methods.

Copilot uses AI. Check for mistakes.
{
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<int, int> fibonacci = (int n) =>
// vs.

int CalcFib5()
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name should use PascalCase according to .NET naming conventions. Consider renaming to "CalculateFib5" or "GetFibonacci5" to follow standard .NET naming conventions for public methods.

Copilot uses AI. Check for mistakes.
{
return n <= 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2);
};
// csharp_style_prefer_local_over_anonymous_function = false
Func<int, int> fibonacci = (int n) =>
{
return n <= 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2);
};

return fibonacci(5);
}
```

## Suppress a warning
Expand Down
Loading