简体   繁体   中英

Global suppression class file for Fxcop

  1. What is the global suppression file actually?
  2. What is the actual file name to be used? Is it GlobalSuppression.cs OR GlobalSuppression* s *.cs ?? (I see a lot of examples which uses both..! So, confused.. eg here )
  3. Should I use this file separately for each assemblies to suppress messages, OR, can I keep a single file which contains message suppressions for all the projects in a solution?

You're describing a feature called CodeAnalysis , available in Visual Studio Premium and Ultimate. It is effectively FxCop integrated into VS. (I've not used it, as I only have VS profressional and have to run FxCop separately).

You can put suppression messages in any file you like, it doesn't have to be called GlobalSuppressions.cs. Just as long as it is included within the project.

GlobalSupressions.cs is the name that Visual Studio's integrated Code Analysis feature uses by default. (Indeed, at the end of the page you've linked there are instruction on how to configure Code Analysis to use a different file).

So, you can include suppressions in a separate file that has no other code in it, like Code Analysis appears to. Or you can include suppressions within an existing file - one of our solutions puts suppressions within each assemblies Proprties.cs file.

As to whether you can keep a single file with all the suppressions for the entire solution, I suspect it depends on what your suppressing and how - I've neve tried it.

You can specify [assembly: SuppressMessage(...)] messages that affect the currently assembly, so wouldn't work in a solution wide file - but you might be able to use the scope = and target = options to make other [module: SuppressMessage(...)] or [SuppressMessage(...)] type messages work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM