Search code examples
c#attributescode-generation

What is the utility of the attribute GeneratedCodeAttribute in C #?


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?


Solution

  • 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.