suppress a few intellisense warnings for all vb projects

Andrew Mercer 441 Reputation points
2021-09-11T10:02:46.43+00:00

In Windows 10, VS 2019 community, I would like to globally suppress a few intellisense warnings. I don't want to do it on a per file, per module, or per project basis. I want to do it once for all time at the visual studio or visual basic scope.

One such example is IDE0017, Object initialization can be simplified. This warning says you should do this:
dim x as new whatever(...) with { .this=that ... }
You should not do this:
dim x as new whatver(...)
x.this=that
...

Well, thanks but no thanks. Too many old projects, no point in messing with them. But I like intellisense, so I would like to suppress this warning one time and forever. And probably a few others. Can't find a way.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,568 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.1K Reputation points
    2021-09-11T12:02:25.707+00:00

    If you go to this line and press <Ctrl+.>, it will show a list of actions, which also includes “Suppress or Configure issues”, where you can choose “Suppress IDE0017” and “in Suppression File”. This will create a special Global Suppression file. Similarly, you can suppress other suggestions, or edit the special file manually. See also the documentation for SuppressMessageAttribute. You can edit or remove the Scope and Target parameters to adjust the area of suppression. If Scope is not present, then the suppression seems to have a global effect.

    See also: https://learn.microsoft.com/en-us/visualstudio/code-quality/in-source-suppression-overview.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Andrew Mercer 441 Reputation points
    2021-09-11T14:07:13.887+00:00

    thanks, you got me going in the right direction. i have a vb file that i include (link to) in all my vb projects. i added the following to this file:

    Imports System.Diagnostics.CodeAnalysis
    <Assembly: SuppressMessage("Style", "IDE0017")>
    <Assembly: SuppressMessage("Style", "IDE0029")>

    since this file is used by all my vb projects, the two suppressions are now applied to all my projects. this gets the job done for me, but it does leave unanswered my OP. I don't think there is a way to do a VS wide suppression, only project (assembly) wide.

    1 person found this answer helpful.
    0 comments No comments