3

Can somebody tell me why code analysis shows issues from generated files? I do check option as here: http://msdn.microsoft.com/en-us/library/dd742298.aspx

I think it has to do with the fact that I use TT tempate with my Entity framework models. But those files have tags on them..

katit
  • 17,375
  • 35
  • 128
  • 256
  • 1
    Not sure what "tags" might mean. The code generator must output the [GeneratedCode] attribute on the generated code to allow the analyzer to recognize that it should ignore the code. – Hans Passant Jun 09 '11 at 21:51

1 Answers1

3

Can you have your TT templates output the following into the header?

//<autogenerated/>

Or to be more specific to certain items in file:

[GeneratedCode("MyTool", "1.0")]
public partial class GeneratedModel
{
...
user7116
  • 63,008
  • 17
  • 141
  • 172
  • Yes, I made TT template to output attribute. Then code analysis stopped looking at those. comment on top doesn't work. Thanks! – katit Jun 09 '11 at 22:05
  • file header comment with a - "auto-generated" is how StyleCop's "Style Analysis" supposedly ignores files. – felickz Jul 24 '12 at 15:06
  • I couldn't make the first one work in VS2012 Code Analysis. The second one however was perfect. Thanks. – NotMe Oct 02 '12 at 01:56