Code actions to configure severity and IDE code style options with .editorconfig#35691
Conversation
src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/Core/Implementation/CodeActions/CodeActionEditHandlerService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
i thought i wrote a comment why we have this behavior :) can we move it over as well?
There was a problem hiding this comment.
I did not find any comment in the original code, but I have tried to retain the original semantics.
|
Pausing on this to try to figure out a good way to order the review. |
|
@mavasani Is this something we can break into multiple commits? |
Let me break this into separate commits and force push... |
5c9bd54 to
35bf81b
Compare
|
@jasonmalinowski @CyrusNajmabadi I have updated the PR to be split into multiple commits, hopefully it is easier to review.
I will now work on refactoring/sharing more code for analyzer config documents. Note that it is likely going to lead to helper methods with bunch of ugly lambdas, but probably that is better then cloning large pieces of code. |
|
@mavasani Thanks for putting in that effort! |
src/Workspaces/Core/Portable/Shared/Extensions/ISolutionExtensions.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Shared/Extensions/ISolutionExtensions.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Shared/Extensions/TextDocumentExtensions.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Workspace/Solution/ProjectChanges.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Workspace/Solution/ProjectChanges.cs
Outdated
Show resolved
Hide resolved
Note: the above commits look like they could be broken out into their own PR without the feature. Up to you if you want to do that.
|
src/VisualStudio/Core/Def/Implementation/Preview/PreviewUpdater.PreviewDialogWorkspace.cs
Outdated
Show resolved
Hide resolved
src/VisualStudio/Core/Def/Implementation/Preview/PreviewUpdater.PreviewDialogWorkspace.cs
Outdated
Show resolved
Hide resolved
src/VisualStudio/Core/Def/Implementation/Preview/TopLevelChange.cs
Outdated
Show resolved
Hide resolved
src/VisualStudio/Core/Def/Implementation/Preview/TopLevelChange.cs
Outdated
Show resolved
Hide resolved
.../Implementation/ProjectSystem/VisualStudioWorkspaceImpl.AddAnalyzerConfigDocumentUndoUnit.cs
Outdated
Show resolved
Hide resolved
@mavasani Thanks for the change! I'm much happier with it. It def satisfies at least one of my goals, which is that the beahvior and description of the feature is contained within the feature itself. My other goal (which is absolutely not required and can come later) would be that this be a general part of the code-fixer infrastructure, and not limited to just our internal features. My objection is withdrawn on that commit now. Thanks! |
|
@CyrusNajmabadi I have addressed most of your review feedback with the latest commit. @dotnet/roslyn-ide @heejaechang - would you be able to review this PR? |
@mavasani Thanks! Will try to review this this weekend. I don't expect any issues, your responses all seemed sensible to me :) |
…values from the light bulb. We support configuration for boolean and enum based code style option values. The only unsupported current code style option from this fixer is specification of modifiers order, which is a custom user supplied string.
|
FYI: I have pushed a new commit f1511b8, which adds a configuration fixer to enable configuring IDE code style option values from the lightbulb. I have updated the PR description and screenshots. Tagging @jinujoseph @kendrahavens @mikadumont |
|
I currently chose the implementation to add/update all code style option based entries instead of using
|
src/Features/Core/Portable/CodeFixes/Configuration/ConfigurationUpdater.cs
Show resolved
Hide resolved
...rpTest/Diagnostics/Configuration/ConfigureCodeStyle/EnumCodeStyleOptionConfigurationTests.cs
Show resolved
Hide resolved
… ConfigureEditorConfig


This PR revives the work done in #29332 to add a code action to configure severity of diagnostics and code action to configure code style option values. Unlike that PR, which relied on .editorconfig being marked as an additional file, this PR uses the newly added
AnalyzerConfigDocumentfor .editorconfig files. Screenshots and a small working snippet is attached below:Top level menu: Now we nest all configure and suppress code actions into a sub-menu to avoid clutter in lightbulb

Create new .editorconfig with configured code style option value:

Update existing .editorconfig with new code style option value:

Create new .editorconfig with configured severity (also works for 3rd party analyzers):

Update existing .editorconfig with new severity (also works for 3rd party analyzers):

Supports different syntax for IDE diagnostics with code style option(s):

Code action snippet:

NOTE: I also had to thread through AnalyzerConfigDocuments at bunch of places in the workspace layer to get the creating/updating of this new document kind via a code action to work as expected. I have added relevant tests.
Future enhancements:
Current code fix only adds/updates a single closest .editorconfig relative to the file with the diagnostic. In future, we might want to enable customization of this via options.