Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Exclude compiler generated code from coverage?
ndeslandes
#1 Posted : Wednesday, February 12, 2014 11:00:05 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/12/2014(UTC)
Posts: 10
Location: United Kingdom

Thanks: 2 times
Was thanked: 3 time(s) in 2 post(s)
Hi,

I love the support for the ExcludeFromCodeCoverage attribute. Is there a way to indicate other attributes that should exclude class and methods from the coverage report?

The main use I would have for it would be to exclude compiler generate code, such as this:

Code:

    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class Resources
    {

        private static global::System.Resources.ResourceManager resourceMan;

        private static global::System.Globalization.CultureInfo resourceCulture;

        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal Resources()
        {
        }

        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager
        {
            get
            {
                if ((resourceMan == null))
                {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BP.FofToLimUploader.Gui.Properties.Resources", typeof(Resources).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }



Unfortunately this class isn't partial, so I can't manually add the ExcludeFromCoverage attribute, and so it always shows in the NCrunch metrics unless manually excluded in the GUI.
DotCover allows you to add any attribute in the list of attributes that should exclude coverage, which solved this issue quite nicely.

Is there a way to do something similar in NCrunch?

Thanks,

Nico
Remco
#2 Posted : Wednesday, February 12, 2014 12:35:20 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Nico,

Thanks for sharing this request.

What is your purpose behind excluding this code from NCrunch's coverage? Is it just to try and remove the distortion from the Metrics Window? Or are you trying to improve performance?

If adjusting the metrics is your intention, I recommend using the exclusion filter in the Metrics Window. This can be used to exclude the code at file-level so it will not impact your coverage percentages, alleviating the need for any code changes or attributes.

I'm afraid there's nothing better that I can recommend at this stage.


Cheers,

Remco
ndeslandes
#3 Posted : Wednesday, March 5, 2014 9:59:58 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/12/2014(UTC)
Posts: 10
Location: United Kingdom

Thanks: 2 times
Was thanked: 3 time(s) in 2 post(s)
Hi Remco,

Thanks for your reply, which I unfortunately missed...
The main purpose is indeed to remove the distortion from the metric window. I have used Metrics Window filter, which was fine in my case since I'm working on a small-ish project right time.
This would've been much more painful in a very large project, where possibly hundreds of manual exclusions would have to be done by every developer... Being able to automate that with a single configuration setting would be really valuable.

Cheers,

Nico
Remco
#4 Posted : Wednesday, March 5, 2014 10:13:17 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks Nico - I'll look into it :)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.036 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download