Is it possible to exclude a complete namespace from all FxCop analysis while still analyzing the rest of the assembly using the SuppressMessageAttribute
?
In my current case, I have a bunch of classes generated by LINQ to SQL which cause a lot of FxCop issues, and obviously, I will not modify all of those to match FxCop standards, as a lot of those modifications would be gone if I re-generated the classes.
I know that FxCop has a project option to suppress analysis on generated code, but it does not seem to recognize the entity and context classes created by LINQ 2 SQL as generated code.
If you tag your classes with the [GeneratedCode]
attribute, you can use the /ignoregeneratedcode flag with FxCop as described in this MSDN post:
FAQ: How do I prevent FxCop from firing warnings against generated code
You may have to add a new code file and implement new partial classes there to add the attribute to the classes:
[GeneratedCode]
public partial class MainDataContext { }
Just make sure you add everything to the correct namespace when you create your new file.