V5 Documentation


NCrunch.Framework Attribute


This attribute controls whether NCrunch RDI is enabled for the associated test(s). It can be applied at assembly, fixture or test level.

Any attempt to open an RDI overlay for a test with RDI disabled will result in an error being shown in the UI. A test with RDI disabled will record no RDI data, regardless of whether it is executed locally or on a remote grid node.

Declaration In NCrunch.Framework.dll

namespace NCrunch.Framework
    public class EnableRdiAttribute: Attribute
        public EnableRdiAttribute(bool enableRdi)
            Value = enableRdi;

        public bool Value
            get; private set;

You can declare this in your own code if you want NCrunch to use it - or otherwise reference the attribute from NCrunch.Framework.dll.

Usage example

public void MyTest()


Generally, this attribute is only used to disable RDI rather than enable it. This is because RDI is also controlled at project level through the Enable RDI setting. Projects that disable RDI using this setting can have no RDI data collected even if the tests involved specifically have RDI enabled using NCrunch.Framework.EnableRdiAttribute.

One potential reason for enabling RDI using this attribute is if a test is inheriting it from a base class or assembly-level attribute and wishes to override the behaviour.

Disabling RDI using this attribute is recommended for tests that do not work well with RDI. This may include include the following kinds of tests:

  • Performance tests: Some tests are designed to hammer areas of code to measure their performance. RDI's instrumentation adds significant weight to code and will disrupt the measurement of these tests by affecting wall time.
  • Extremely large tests: Tests that cover large amounts of code and contain many paths of frequent execution may perform very poorly under RDI. This is because RDI data limits are tracked on a per-method bases. A test that covers many methods can record much more data before hitting limits.

Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download