How to set up modular input debugging using the Splunk extension for Visual Studio

The Splunk extension for Visual Studio automatically includes a block of code in the modular input template that simplifies debugging setup. For more information about debugging modular inputs in the Splunk SDK for C#, see How to debug modular inputs in Splunk SDK for C# v2.x.

When you generate a new modular input using the template that is provided by the extension, the template automatically injects a code block at the top to make it easier to turn on debugging. The block uses conditional compilation constants, which means you can turn on debugging without having to touch the code.

The code block, in its entirety, follows:

public static int Main(string[] args)
    uint timeout_sec = 30;

    // To enable attaching to the input running in Splunk to debug, set the 
    // DEBUG_VALIDATE or DEBUG_STREAMEVENTS compilation constants
    // in the project settings

    return Run<Program>(args, DebuggerAttachPoints.ValidateArguments, timeout_sec);
    return Run<Program>(args, DebuggerAttachPoints.StreamEvents, timeout_sec);
    return Run<Program>(args);