Open mavasani opened 4 years ago
@sharwell mentioned this is a duplicate of https://github.com/dotnet/roslyn/issues/26531#issuecomment-582558152.
I am going to repurpose this issue to a pure design/code style issue to finalize the desired build enforcement for Roslyn IDE layers.
However, due to #44201, we are forced to add the below entry to editorconfig to get build time enforcement:
This is the problem #27712 aimed to solve.
I found a workaround for this issue: https://github.com/dotnet/winforms/commit/e8e42f7
Consider the below test snippet, with the desired IDE0007 diagnostics:
Ideally, the following settings would suffice to get the above behavior:
However, due to https://github.com/dotnet/roslyn/issues/44201, we are forced to add the below entry to editorconfig to get build time enforcement:
This in turn bumps up all the 3 buckets of
csharp_style_var
violations to warnings, so you end up warnings for all the 4 local declarations above:So, the only alternative to turn off
csharp_style_var_elsewhere
andcsharp_style_var_when_type_is_apparent
as follows:This gives correct enforcement for the first case, but not second. Assuming the second case is disregarded, you still lose the suggestions (three dots '...') for all but warning cases.
We do get a refactoring "use implicit type" for these cases, but they will be bumped down the list if you have any other code fixes in the list, for example:
I think the root cause for all these issues is that we use same diagnostic ID
IDE0007
for all thecsharp_style_var
code style options.