Thoughts on FxCop (.NET)

FxCop is very useful tool for code review. I was doing a study on it, And some crazy thoughts raised on my mind... what will happen if FxCop is run on FxCop.exe...? FxCop came clean. No Active errors! But there were 135 errors but under "Excluded in source" section.

Then another crazy thought raised in my mind... what will happen if FxCop is run on .NET core dlls...Here FxCop came Nasty! There were thousands of Active errors! Why didn't Microsoft comply with FxCop?A fourm reply said "FxCop was designed and generated long after the original framework design was in place
"http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/5abda75d-1177-4a91-9b20-dd17c42d4567 Tidbit: How to mark a bug as “Excluded in source”? Code that causes the error should be marked with this C# attribute “CodeAnalysis.SuppressMessageAttribute” Example: [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1804:RemoveUnusedLocals")] private void test() { string name; //unused variable // some code here } Please note that above exclusion will only work if “CODE_ANALYSIS” compiler directive is added to project properties.

No comments:

Post a Comment