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

I am trying to run code analysis on an assembly containing an entity model (edmx file). In the project properties, I checked the Suppress Generated Code Results option, but I still get a lot of CA errors related to the auto-generated EF code.

Has anyone experienced this? And is there any work?

+6
visual-studio-2010 entity-framework code-analysis
source share
2 answers

Well, "Suppress generated code results" really means "Don't look at types with GeneratedCodeAttribute ." The EF code generator did not add this, historically (although I suggested it to the team). But you can add it if you use custom T4 .

+7
source share

Just put the attribute in the class definition.

But how to do this, since your file can be overridden at 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 the code analysis for your specific generated class. StyleCop, for example, is smarter and does not apply to files that have a .designer/.generated part in their name or regions that have a generated word in their name.

+10
source share

All Articles