question

AndrewMercer-9876 avatar image
0 Votes"
AndrewMercer-9876 asked AndrewMercer-9876 answered

suppress a few intellisense warnings for all vb projects

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.

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

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://docs.microsoft.com/en-us/visualstudio/code-quality/in-source-suppression-overview.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndrewMercer-9876 avatar image
0 Votes"
AndrewMercer-9876 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.