diff --git a/docs/fundamentals/code-analysis/style-rules/ide0059.md b/docs/fundamentals/code-analysis/style-rules/ide0059.md index 95b86af41e900..a4712a7f63340 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0059.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0059.md @@ -1,7 +1,7 @@ --- title: "IDE0059" description: "Learn about code analysis style rule IDE0059." -ms.date: 12/13/2023 +ms.date: 01/05/2026 f1_keywords: - IDE0059 - csharp_style_unused_value_assignment_preference @@ -55,6 +55,23 @@ You can take one of the following actions to fix this violation: int v = Compute2(); ``` +## Known limitations + +This rule doesn't work in certain code contexts. The analyzer fails to flag unnecessary value assignments in the following scenarios: + +- Assignments inside `try` or `catch` blocks. +- Assignments inside `using` statement blocks. +- Variables assigned within lambda expressions or delegate bodies. +- Variables in the presence of expression trees (`Expression>`). + +These limitations are tracked in the following GitHub issues: + +- [IDE0059 is not always reported](https://github.com/dotnet/roslyn/issues/52292) +- [Detection of IDE0059 not working within try/catch statements](https://github.com/dotnet/roslyn/issues/65220) +- [IDE0059 not raised inside a code block with using keyword](https://github.com/dotnet/roslyn/issues/74219) +- [IDE0059 doesn't work with expression trees](https://github.com/dotnet/roslyn/issues/80033) +- [Remove unused variable/values (parent issue)](https://github.com/dotnet/roslyn/issues/75737) + ## Options The options for this specify whether to prefer the use of a discard or an unused local variable: