V5 Documentation


NCrunch.Framework Attribute Introduced NCrunch v5.0


This attribute controls the RDI string length limit for the associated test(s). It can be applied at assembly, fixture or test level.

The limit assigned by this attribute will override any limit assigned by config setting.

Declaration In NCrunch.Framework.dll

namespace NCrunch.Framework
    public class StringLengthLimitAttribute: Attribute
        public StringLengthLimitAttribute(int stringLengthLimitInChars)
            Value = stringLengthLimitInChars;

        public int 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()


Adjusting the string length limit for a specific test (or group of tests) can be useful to fine-tune the amount of string data required to be available for RDI. Tests that do extensive processing with longer strings may be difficult to analyse when the limit is set too low.

Internally, RDI implements systems to reduce the redundancy of string data in the log. When working efficiently, these systems somewhat alleviate the benefits of setting a low string length limit. However, these systems do not work efficiently for tests that perform extensive manipulation of large strings (i.e. concatenation, replace, etc). Finding the ideal string length limit for a test may require experimentation.

The behaviour of this setting can be overridden for specific code regions using the string length limit inline directive.

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