1

I am busy with a console application, being a CLI to an API class that provides top level public methods for a data integration process. During development, it is necessary for me to frequently change the command line arguments in the project settings, debug section.

I am looking for a way to do this dynamically while avoiding the cost of a rebuild after each change a clumsy solution such as explicitly setting values in the string[] args parameter list for entry point Main.

The first solution that springs to mind is a custom config section in app.config, where I can define a collection of various command lines, each being a list of name-value pairs, and specify in an attribute of the command line collection which one should be active. The active command's name-value pairs will then be dynamically injected into said string[] args parameter list by static, non-changing code.

Is there any other way to achieve this?

tshepang
  • 12,111
  • 21
  • 91
  • 136
ProfK
  • 49,207
  • 121
  • 399
  • 775
  • Just read them from a text file. Same idea as the [@ option](http://msdn.microsoft.com/en-us/library/8a1fs1tb%28v=VS.90%29.aspx) that the C# compiler accepts. Keep the file opened in an editor tab to quickly make changes. – Hans Passant Apr 29 '13 at 17:51

1 Answers1

0

one thing I can think of is using quickwatch to alter the commandline array

Suppose you have the following code:

public static void Main(string[] arg)
{
    string s = arg[0];
}

Put a breakpoint on the first line and press shift f9 after selecting arg. This will open the quickwatch and in the expression field reallocate the array while copying the old values into it.

arg = new string[3] { arg[0], arg[1], "test" }
Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98
  • I normally use the immediate window for things like that, but for this project that would quickly become burdensome. – ProfK Apr 29 '13 at 17:22