How to disable specific suggestions from appearing in message tab, but keep them inline in visual studio 2019

Viewed 481

I'm currently migrating a project from .netcore 3.1 to .net 5. This introduces a simplified way of creating objects:

object example = new();

However the project uses the 'normal' way as new() did not exist when it was created:

object example = new object();

This causes a great deal of messages to show up in the error list, which hides messages in the list that I might want to keep. I would like to prevent that suggestion from showing up in the list, but keep them when I'm in files. I know I can disable/hide the suggestion all together using editor config, visual studio tells as much. But can I also use editor config to stop it from appearing in just the error list? If so, how?

1 Answers

Simply change the severity of the specific Code, for example IDE0090, from Default to Silent/None or open the .editorconfig file and then add the related command like

IDE0090: Use 'new(...)'

dotnet_diagnostic.IDE0090.severity = silent

will disable/hide the suggestions in the error list.

You mentioned you want to keep them when you are in files, does it mean that the suggestions disappear in Error List but still appear when you click the bulb in source codes? Not sure whether set the severity to silent could meet your requirement. If not, then I think this is not possible, as the severity is set for the analyzer and all prompt areas use and display the information from the same analyzer, also there is no other option to choose to display or not display the specific message.

Screenshot when set to silent:

enter image description here

Related documents: Configure severity levels, and Example EditorConfig file

Related