问题
I marked all instances of InitializeComponent with
<CodeDom.Compiler.GeneratedCode("WinForms Designer", "")>
So those will not show up during code metrics analysis. The rest of the generated code is still considered mine, particularly setters and getters for each control. Marking the whole partial class (the winforms designer part) with GeneratedCode makes the whole class disappear from code metrics, so even my custom logic. I am using Visual Studio 2010.
回答1:
Code Metrics does not ignore Form classes on purpose see http://msdn.microsoft.com/en-us/library/bb385914.aspx
Code generated for Windows forms is not ignored, because it is code that the developer can see and change.
Perhaps the Code Metrics Viewer extension will do what you want.
来源:https://stackoverflow.com/questions/12306263/how-to-properly-mark-designer-code-for-code-metrics-to-ignore-it