I generated some of my C# code with an external tool. Each generated class has an attribute GeneratedCodeAttribute. Why is my generator creating this attribute?
It is most probably used by the generator to find back the elements it created, in order to perform updates for example. Beware if you modify generated code : depending on the tool behaviour, you may loose your modifications on a further update.
This attribute was set because this code is generated by tool, not by human :) what is use of it you might ask? MSDN tells us:
The GeneratedCodeAttribute class can be used by code analysis tools to identify computer-generated code, and to provide an analysis based on the tool and the version of the tool that generated the code.
One potential use is that Some coverage tools can skip code based on specified attributes. You can tell NCover to ignore code with this attribute.
The first link is its documentation and the second link is a detailed description of what this is for, why code generators produce it, and how code analyzers consume it.
http://msdn.microsoft.com/en-us/library/system.codedom.compiler.generatedcodeattribute.aspx
and
Does that answer your question?