I am using FxCopCmd tool for static code analysis. Since we already had a huge codebase, we baselined existing issues using baseline.exe tool that comes with FxCop.
I am observing that if I add a new method to my C# class, then some of the suppression messages in GlobalSuppression.cs file stop working and I get issues for the code I haven't touched.
public async Task<string> method1()
string a = "";
static void Main(string args)
CA1031 : Microsoft.Design : Modify 'Program.d__0.MoveNext()'
to catch a more specific exception than 'Exception' or rethrow the
[module: SuppressMessage("Microsoft.Globalization", "CA1309:UseOrdinalStringComparison", Scope="member",
So even after setting bounty, the question went unanswered. However, I found the workaround (if not the solution).
The mentioned problem is due to compiler generated code for async methods. Since FxCopCmd runs on dll, as compiler generated code is changed, the existing suppression messages get useless. However, Visual Studio doesn't run code analysis by merely using FxCopCmd. It runs code analysis intelligently ignoring async methods. (As per my investigation, it doesn't run any kind of code analysis on async methods. It must be due to the problem in question.)
To get the same behavior as Visual Studio in CI builds, we can use fxcoptask.dll for running FxCop analysis on code. Refer to this answer to know how to integrate FxCop in the build. This will solve the issues mentioned in the problem. Also, it gives a lot of customization options.