Enforcing IDE0007 (Use implicit type) as a build warning for only one of three supported var code style options seems difficult #44250
Labels
Area-IDE
Bug
Feature - IDE0007
Use implicit type
IDE-CodeStyle
Built-in analyzers, fixes, and refactorings
Milestone
Consider the below test snippet, with the desired IDE0007 diagnostics:
Ideally, the following settings would suffice to get the above behavior:
However, due to #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
![image](https://user-images.githubusercontent.com/10605811/81948698-e104dc00-95b6-11ea-9258-c638f0807188.png)
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.
![image](https://user-images.githubusercontent.com/10605811/81949059-3e992880-95b7-11ea-8214-03f6a0537445.png)
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:
![image](https://user-images.githubusercontent.com/10605811/81949428-b36c6280-95b7-11ea-86cb-f228aa6f4350.png)
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.The text was updated successfully, but these errors were encountered: