Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CA: Suppress results from generated code not working in VS2010 beta 2

I'm trying to run codeanalysis on an assembly that contains an entity model (edmx file). In project properties I have checked the "Suppress results from generated code" option, but I am still getting a lot of CA errors pertaining to the auto-generated EF code.

Has anyone experienced this? And is there a work-around?

like image 958
Klaus Byskov Pedersen Avatar asked Mar 16 '10 10:03

Klaus Byskov Pedersen


1 Answers

Just put the attribute on your class definition.

But how to do it, since your file can get overridden any time. Use a separate file, since all generated classes are partial classes. Open a separate file, and write something like:

[GeneratedCode("EntityModelCodeGenerator", "4.0.0.0")]
public partial class YourEntitiesContextName : ObjectContext
{
}

This will skip code analysis on your particular generated class. StyleCop for instance is more smart and doesn't touch files that have .designer/.generated part in their name or regions that have generated word in their name.

like image 73
Robert Koritnik Avatar answered Sep 22 '22 22:09

Robert Koritnik