Click or drag to resize

Stepping Into or Over Injected Calls to NCL Code

The steps outlined below explain how to step into or over the code that the Nimbus code weaver injects into driver methods, properties and events during code weaving.

Note Note

By default, Visual Studio steps over calls to property getters and setters. If you're trying to step into properties, follow the instructions here to configure Visual Studio to step into properties before proceeding.

The procedures below show the behavior of the Visual Studio debugger for the Configure method shown below.

C#
[DriverMethod]
[InvalidateCacheEntries("Frequency")]
public void Configure(double resBW, double videoBW, double sweepTime)
{
    if (this.Session.InitOptions.SimulationEnabled)
    {
        return;
    }

    this.IO.FormattedIO.PrintfAndFlush("SENS:BAND%0.15g; SWE:TIME%d; BAND:VID%3.2f;\n", resBW, sweepTime, videoBW);
}

Figure 1 illustrates what that method would look like after being built, when viewed using .NET Reflector.

Figure 1: A Configure Method (as seen in .NET Reflector)

Note that, based on the attributes applied to this method, the Nimbus code weaver has injected the standard thread synchronization preamble and object disposed check, as well as a call to the InvalidateCacheEntry(String) method, which is defined on the DriverNode base class that Nimbus-generated classes derive from.

Figure 2 shows a debugging session that's currently poised to call to that Configure method from within the standard Nimbus-generated unit test method.

Figure 2: Configure Method Unit Test

At this point, if you were to use the Visual Studio Step Over command (F10 typically), the Configure method would be invoked in its entirety, and then the debugger would stop on the closing curly brace at the end of the unit test method. However, if you were to use the Visual Studio Step Into command (F11 typically), the debugger would take you to the opening curly brace of the Configure method, as shown in Figure 3.

Figure 3: Stepping Into the Configure Method

Depending on what you do next, you can either step over the injected calls to Nimbus Class Library code, or step into the injected calls to Nimbus Class Library code.

Stepping Over Code Weaver-Injected Code

  • With execution positioned at the opening curly brace of a driver method, property accessor, event accessor, simply use the Step Over command (F10) to run until you reach the first line of code within your method, property or event body.

Stepping Into Code Weaver-Injected Code

  1. With execution positioned at the opening curly brace of a driver method, property accessor, event accessor, simply use the Step Into command (F11) to run until you reach the first line of code within your method, property or event body.

    For example, using the Step Into command (F11) when execution is positioned on the opening curly brace of the of the Configure method shown above will take you to the start of the AcquireLock method, as show in Figure 4.

    Figure 4: Stepping Into Nimbus Class Library Code
  2. Step through the Nimbus Class Library code as desired.

    Tip Tip

    To facilitate quickly getting back to the first line of code within the body of your driver method, property or event, set a breakpoint on the first line of code after the opening curly brace for your driver method, property or event before using the Step Into command (F11) to begin stepping through injected calls to Nimbus Class Library code. When you're ready to quickly proceed to the start of your driver method, property or event, use the debugger Continue command (F5 typically) to execute until your breakpoint is reached.

Configuring Visual Studio to Step Into Properties

  1. Click on Tools then Options to bring up the Visual Studio preference dialog.

  2. Expand the Debugging node in the tree view on the left and click on General. This will display several checkbox options on the right.

  3. Clear the checkbox labeled Step over properties and operators (Managed only). This is illustrated by Figure 5.

    Figure 5: Configuring Visual Studio to Step Into Properties
See Also

Download a complete CHM version of this documentation here.