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:

  1. Open the attached console app project: ConsoleApp242.zip
  2. In Program.cs, click on line 10, and open the lightbulb menu
  3. 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:

  1. git clone http://github.com/dotnet/project-system
  2. cd project-system
  3. `git checkout f10010447871843997a26ceecd60663557ce815d
  4. ProjectSystem.sln
  5. 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.
  1. Using either the error list or editor to set severity to warning:

image

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)

Most upvoted comments

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.

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.

  1. 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-L188
  2. I verified that the repro leads to appropriate text change in the workspace and correct text edit application to the buffer.
  3. When the control reaches InvisibleEditor.Dispose, the field _buffer has the changed text, but runningDocumentTable.SaveDocuments does not seem to save the changes.
  4. I also tried updating the option passed to 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…