MicrosoftPremier / VstsExtensions

Documentation and issue tracking for Microsoft Premier Services Visual Studio Team Services Extensions
MIT License
56 stars 14 forks source link

How to ignore warning #48

Closed Djedjeridoo closed 4 years ago

Djedjeridoo commented 4 years ago

Hello, I would like to ignore some of the warnings so that they are not counted.

For example, for warning CS0612 and CS0618, if I indicate the following regex in the "Warning Filter" field: ^(((?!CS0612|CS0618).)*$

I get the following result: 2019-10-14T10:22:04:04.3870956Z Total warnings: NaN 2019-10-14T10:22:04.04.3870956Z Filtered warnings: NaN

Can you tell me which regex to use? Thanks a lot !

please note that I am using an old version 2.8.1 with TFS2015 and VS2015. warningfilter

ReneSchumacher commented 4 years ago

Hi @Djedjeridoo,

since warning filters are used to only count warnings that match the filter expression, it is pretty hard to create a regular expression that correctly matches all warnings except just the two. I would recommend using an appropriate compiler directive (#pragma warning) in your code instead (see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-pragma-warning). Would that be possible in your case?

Thanks, René

Djedjeridoo commented 4 years ago

Hi @ReneSchumacher Thank you for your answer In fact, using a preprocessor directive is not applicable in our case.

We use your fabulous tool to reduce the number of warnings in the project. However, some warnings, such as the CS0612 warning, increase the number of warnings because they are triggered by all functions that call the one marked [Obsolete]. So, when the developer marks a function [Obsolete] it does not generate 1 warning but can potentially generate hundreds. For example, currently we have 50 warnings on 300,000 lines of code, but by refactoring and introducing some obsolete functions, we end up with more than 1000 warnings.

The warnings need to be displayed in Visual Studio, so developers can fix them. Developers should not ignore them, but the Build should ignore them....

Thanks Dje

chvollm commented 4 years ago

Hi @Djedjeridoo you can suppress the C# warning from the command line just for the build. See https://stackoverflow.com/questions/1023858/how-to-suppress-specific-msbuild-warning. Does that help? Regards, Christoph

Djedjeridoo commented 4 years ago

Great and Perfect !! Thanks a lot for your solution.

Regards. Dje