Click or drag to resize

Suppressing Code Weaving

Should the need arise, the Nimbus code weaver can be disabled in two different ways:

  • On a per-method, per-property or per-event basis. This approach allows you to exempt specific code members from code weaving without disabling code weaving for your entire driver. The procedure for this is described here.

  • On a project-wide basis. This approach allows you to disable (and later reinstate) code weaving for the entire driver. The procedure for this is described here.

Both approaches allow you to enable and disable code weaving as needed without requiring any changes to code you've written or designer-driven changes you may have made.

Disable code weaving for an individual method, property or event

  1. From the driver designer, right click on the property, method or event for which you wish to disable code weaving and select Go to Implementation.

  2. Locate the DriverProperty, DriverMethod or DriverEvent attribute that appears above the implementation.

  3. Update the attribute declaration to set the named parameter SuppressAll to true, as shown below for a Frequency property.

    C#
    [DriverProperty(SuppressAll = true)] // Code weaving disabled for this property.
    [Cache]
    [InvalidateCacheEntries("Bandwidth")]
    [RangeCheckMinMax(0, 300, MaxInclusive = true)]
    public double Frequency
    {
        get
        {
            this.IO.FormattedIO.PrintfAndFlush("FREQ:RANG\n");
            double value;
            this.IO.FormattedIO.Scanf("%g", out value);
    
            return value;
        }
        set
        {
            this.IO.FormattedIO.PrintfAndFlush("FREQ:RANG %0.15g\n", value);
        }
    }
  4. Rebuild the driver.

    Note Note

    With this technique, other attributes that may have been added to your method, property or event by the driver designer are not modified and will remain in the source code. However, the Nimbus code weaver will ignore those attributes at build time as long as SuppressAll is set to true. To reinstate code weaving for the selected method, property or event, change the value of SuppressAll to false, or remove the use of the SuppressAll named parameter altogether.

Disable code weaving for the entire driver

  1. From Solution Explorer, right click on the driver project node (the C# assembly, not the Nimbus node) and choose Properties. This will display the standard project properties page for a C# class library assembly.

  2. Select the Build properties tab.

  3. Locate the Conditional compilation symbols field.

  4. If the Conditional compilation symbols field is empty, enter DisableNimbusCodeWeaving. If the Conditional compilation symbols field is not empty, enter a semicolon after the existing value(s), followed by DisableNimbusCodeWeaving. This is illutrated in Figure 2.

    Figure 2: Code Weaving Disabled for the Entire Driver
  5. Rebuild the driver.

    Note Note

    With this technique, code weaving can be enabled and disabled for the entire driver project without affecting the driver designer or any of your source code. To reinstate code weaving for your driver, simply remove the DisableNimbusCodeWeaving conditional compilation symbol.

See Also

Download a complete CHM version of this documentation here.