RCS1051: consider option `do_not_parenthesize_singleline_conditional_expression`
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 294
- Avg merge
- 2h 30m
- Merged PRs (30d)
- 4
Description
[RCS1051](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1051.md)
**Product and Version Used**:
Microsoft Visual Studio Community 2019 Version 16.10.1
Roslynator.Analyzers 3.2.0 via Nuget
**Steps to Reproduce**:
.editorconfig:
```
dotnet_diagnostic.RCS1051.severity = warning
roslynator.RCS1051.do_not_parenthesize_single_token = true
```
```csharp
public class Foo
{
public bool Bar { get; }
}
...
var foo = new Foo();
foo.Bar ? 42 : 666; // <-
```
**Actual Behavior**:
Get diagnostic for RCS1051.
**Expected Behavior**:
No diagnostic for RCS1051.
If we add parentheses, then [IDE0047](https://docs.microsoft.com/ru-ru/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048) works. Perhaps the new option `do_not_parenthesize_singleline_conditional_expression = bool` for RCS1051 would be helpful for this case.
Contributor guide
Research direction
Start with the linked RCS1051 documentation and reproduce the .editorconfig and C# example from the issue. Check how the existing do_not_parenthesize_single_token option affects the diagnostic. Done means the proposed single-line conditional option prevents the diagnostic for this case without changing other RCS1051 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100