roslyn: Setting severity on a analyzer message does nothing
Version Used: Version 16.7.0 Preview 4.0 [30222.171.master]
Repro 1
Steps to Reproduce:
- Open the attached console app project: ConsoleApp242.zip
- In Program.cs, click on line 10, and open the lightbulb menu
- Try to use any of the “Configure” options to change the .editorconfig file
Expected Behavior: The .editorconfig file is modified appropriately
Actual Behavior: The .editorconfig file is not modified and the lightbulb doesn’t go away. This is more annoying in projects where the specific analyzer raises an error or a warning.
Repro 2
Steps to Reproduce:
git clone http://github.com/dotnet/project-system
cd project-system
- `git checkout f10010447871843997a26ceecd60663557ce815d
ProjectSystem.sln
- Navigate to src\Microsoft.VisualStudio.ProjectSystem.Managed.VS\ProjectSystem\VS\Rename\RenamerProjectTreeActionHandler.cs
– Get the following –
Severity Code Description Project File Line Suppression State Detail Description
Message IDE0059 Unnecessary assignment of a value to 'e' Microsoft.VisualStudio.ProjectSystem.Managed.VS C:\project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed.VS\ProjectSystem\VS\Rename\RenamerProjectTreeActionHandler.cs 166 Active Avoid unnecessary value assignments in your code, as these likely indicate redundant value computations. If the value computation is not redundant and you intend to retain the assignment, then change the assignment target to a local variable whose name starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.
- Using either the error list or editor to set severity to warning:
Expected Behavior: EditorConfig to change
Actual Behavior: Nothing
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 22
- Comments: 18 (15 by maintainers)
What you can do while the problem is not fixed is add the the .editorconfig file in a Solution Folder (right click the Solution and add new Solution Folder), then open the .editorconfig file inside VS, leave it open, then go and configure the style, this worked for me.
Hi, just to say this is still an issue as of latest VS 2022 v17.3.2. Both from Lightbulb and errors list. This makes configuring code analysis in the .editorconfig file difficult.
@rafaelf82 Thanks! Thanks worked a treat.
Tagging @jasonmalinowski, who can help root cause or direct this issue to the correct team, if external.
This seems to be a regression in InvisibleEditor/RunningDocumentTable functionality in how document save is performed for closed documents. Everything works fine if the .editorconfig is currently open in VS.
InvisibleEditor.Dispose
is suppose to save the text changes to changed closed documents in workspace: https://github.com/dotnet/roslyn/blob/7b4bfaaee2f18496a5fb770322a6ff835e114e14/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs#L140-L188InvisibleEditor.Dispose
, the field_buffer
has the changed text, butrunningDocumentTable.SaveDocuments
does not seem to save the changes.SaveDocuments
from__VSRDTSAVEOPTIONS.RDTSAVEOPT_SaveIfDirty
to__VSRDTSAVEOPTIONS.RDTSAVEOPT_ForceSave
, but that also seems to have no effect.I am not sure if there is a Roslyn regression in how analyzer config documents are registered with running document table OR this is a regression in
runningDocumentTable.SaveDocuments
. I don’t know the contract/semantics of RDT enough to answer this…