-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update configure severity code fix for IDE code style diagnostics to use dotnet_diagnostic entries #47052
Update configure severity code fix for IDE code style diagnostics to use dotnet_diagnostic entries #47052
Conversation
…use dotnet_diagnostic entries Implements changes to configure severity code fix as per dotnet#44201. The code fix now does the following for IDE code style diagnostics: 1. Updates the last applicable existing code style option value based entries, i.e. `"%option_name% = %option_value%:%severity%`, to use the new severity. If no such entries are found, we do not add new code style option value based entries. 2. Updates the last applicable existing severity based entries, i.e. `dotnet_diagnostic.<%DiagnosticId%>.severity = %severity%`, to use the new severity. If no such entries are found, we add a new dotnet_diagnostic based entry with new severity. This ensures couple of things: 1. Allow build enforcement of code style diagnostics as compiler only understands dotnet_diagnostic entries. In absence of these entries, compiler will not even execute the code style analyzers on build as these are hidden diagnostics by default. 2. Consistency in severity configuration entries with third party analyzer diagnostics, which can only use dotnet_diagnostic entries. **Before** ![image](https://user-images.githubusercontent.com/10605811/90942638-72ac9280-e3cb-11ea-9abe-301de0d1dfa8.png) **After** ![image](https://user-images.githubusercontent.com/10605811/90942562-26615280-e3cb-11ea-85d8-202bb7c0d01e.png) **Existing entry** ![image](https://user-images.githubusercontent.com/10605811/90942745-f5355200-e3cb-11ea-9c1f-2e06956a05e7.png) We have follow-up work planned to have some UX to allow viewing and configuring code style option values and severities, so the additional dotnet_diagnostic severity entries in the editorconfig file themselves will not be bothersome for majority of the users.
@@ -355,1652 +358,17 @@ public Customer() | |||
} | |||
} | |||
</Document> | |||
<AnalyzerConfigDocument FilePath=""z:\\.editorconfig"">[*.cs] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were quite a few redundant tests in this file as @jasonmalinowski has observed the last time he touched this file. I deleted some of these duplicates but github diff seems to have royally messed it up and shows me adding large number of new tests and deleting much larger set then were actually deleted. Maybe codeflow has a better diff here?
} | ||
} | ||
|
||
public class SilentConfigurationTests : CodeStyleOptionBasedSeverityConfigurationTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class was not deleted, I just trimmed the number tests inside this class to a much smaller number :-(
@@ -68,6 +68,7 @@ private enum ConfigurationKind | |||
private readonly bool _isPerLanguage; | |||
private readonly Project _project; | |||
private readonly CancellationToken _cancellationToken; | |||
private readonly bool _addNewEntryIfNoExistingEntryFound; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only product file changed in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allisonchou I would really appreciate your review on this file. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ConfigurationUpdater changes LGTM 💯
Thank you @allisonchou! |
Contributes towards dotnet#44201 - All code style option editorconfig entries can now be specified as `option_name = option_value` without `:severity` suffix - `Configure code style option` code fix will no longer add add `:severity` suffix for new entries. For fix that changes existing entries which have `:severity` suffix, it will retain the existing severity suffix. Note that `Configure severity` code fix was already switched to use `dotnet_diagnostic.RuleID.severity` entries for code style diagnostics in dotnet#47052. Once we have the editorconfig UX to change code style option value and severity, we can safely deprecate the `:severity` suffix in option value syntax. All our UI gestures will use the `option_name = option_value` syntax for code style value changes and `dotnet_diagnostic.RuleID.severity = severity` syntax for severity changes and users do not need to deal with these manually editing or understanind these different syntaxes or mapping rule IDs to option names and vice versa for code styles.
Implements changes to configure severity code fix as per #44201. The code fix now does the following for IDE code style diagnostics:
"%option_name% = %option_value%:%severity%
, to use the new severity. If no such entries are found, we do not add new code style option value based entries.dotnet_diagnostic.<%DiagnosticId%>.severity = %severity%
, to use the new severity. If no such entries are found, we add a new dotnet_diagnostic based entry with new severity.This ensures couple of things:
Before
![image](https://user-images.githubusercontent.com/10605811/90942638-72ac9280-e3cb-11ea-9abe-301de0d1dfa8.png)
After (no existing entry)
![image](https://user-images.githubusercontent.com/10605811/90942562-26615280-e3cb-11ea-85d8-202bb7c0d01e.png)
After (with existing entry)
![image](https://user-images.githubusercontent.com/10605811/90942745-f5355200-e3cb-11ea-9c1f-2e06956a05e7.png)
We have follow-up work planned to have some UX to allow viewing and configuring code style option values and severities, so the additional dotnet_diagnostic severity entries in the editorconfig file themselves will not be bothersome for majority of the users.