Tuesday, 13 June 2017

Debugger step through attribute

If you're stepping through your code and you find it just too difficult to hit F10, but you would like to step over a function well you can just mark it with the [DebuggerStepThrough] attribute. This attribute will force your debugger to step over code instead of into it even if you hit F11.

using System;
using System.Diagnostics;

namespace FunctionIgnoreStepThrough
{
    class Program
    {
        static void Main(string[] args)
        {
            string fn = FullName("Pavel""Chooch");
            Console.WriteLine(fn);
        }

        [DebuggerStepThrough]
        static string FullName(string fn, string ln)
        {
            return string.Format("{0} {1}",fn, ln);
        }
    }
}

With this small change now your debugger will skip over the FullName function.