I have Visual Studio 2010 Ultimate and C# and am doing unit tests and viewing code coverage. There are some classes I want to exclude from the code coverage, so I read that you can use the
[ExcludeFromCodeCoverage]
Attribute. The only problem is it causes a red line underneath it and it has the dreaded
Error 16 The type or namespace name ‘ExcludeFromCodeCoverage’ could not be found (are you missing a using directive or an assembly reference?)
What am I doing wrong? I even have a ‘using System.Diagnostics.CodeAnalysis;’ line, and the right click->resolve does not present itself with any fixes.
Doing a Test based on Shaun’s comment, and to be more explicit about the possible solution:
I get a red line under that attribute when my “Target framework” in the project properties page is set to a version less than 4, such as 3.5. Changing the Target framework to version 4 or version 4 client profile, fixed the issue and allowed the attribute to resolve.