When VS 2005 or 2008 generates code (for example, a DataSet generated from a .xsd schema, or when generating the Settings.Designer.cs file), it adds code like the below on generated property members: [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] // ... other attributes not shown as they are not relevant to the discussion public string Foo { get { return this.foo; } }Presumably one reason for adding the DebuggerNonUserCode attribute is to exclude the members from code coverage (as that is the only workaround currently, since there is nothing like an [ExcludeCoverage] attribute (P.S. Wouldn't it be great if there were?)However, code coverage ignores that attribute for properties unless it is applied specifically to the getter (and/or setter) like this: public string Foo { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] // apply to getter get { return this.foo; } // if there were a setter, we'd also need it here [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] // apply to setter set { // do something cool } }Actually, for 2008 it should have just applied the attribute to the whole class like this:[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { // no need to apply the attribute to any members here}(For VS2005 the attribute can be applied to the class, but it is ignored anyway! But VS2008 code coverage seems to take it)1) Please fix code coverage to pick up the attribute correctly2) Please fix code generator to place the attribute correctly3) Better yet, please provide something like an [ExcludeCoverage] attribute to be used by the code coverage system, and make the code generator(s) apply it as well
Version