本文整理汇总了C#中Microsoft.Build.Tasks.CommandLineBuilderExtension.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineBuilderExtension.ToString方法的具体用法?C# CommandLineBuilderExtension.ToString怎么用?C# CommandLineBuilderExtension.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Tasks.CommandLineBuilderExtension
的用法示例。
在下文中一共展示了CommandLineBuilderExtension.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateHasParameter
/*
* Method: ValidateHasParameter
*
* Validates that the the given ToolTaskExtension's command line contains the indicated
* parameter. Returns the index of the parameter that matched.
*
*/
internal static int ValidateHasParameter(ToolTaskExtension t, string parameter, bool useResponseFile)
{
CommandLineBuilderExtension b = new CommandLineBuilderExtension();
if (useResponseFile)
t.AddResponseFileCommands(b);
else
t.AddCommandLineCommands(b);
string cl = b.ToString();
string msg = String.Format("Command-line = [{0}]\r\n", cl);
msg += String.Format(" Searching for [{0}]\r\n", parameter);
string[] pieces = Parse(cl);
int i = 0;
foreach (string s in pieces)
{
msg += String.Format(" Parm = [{0}]\r\n", s);
if (s == parameter)
{
return i;
}
i++;
}
msg += "Not found!\r\n";
Console.WriteLine(msg);
Assert.Fail(msg); // Could not find the parameter.
return 0;
}
示例2: ARFC
public void ARFC (CommandLineBuilderExtension commandLine)
{
base.AddResponseFileCommands (commandLine);
#if !NET_4_0
string s = commandLine.ToString ();
if (s.Length == 6)
Assert.AreEqual ("/sdk:2", s);
else
Assert.AreEqual ("/sdk:2 ", s.Substring (0, 7));
BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
PropertyInfo pi = typeof (CommandLineBuilderExtension).GetProperty ("CommandLine", flags);
System.Text.StringBuilder sb = (System.Text.StringBuilder) pi.GetValue (commandLine, null);
sb.Length = 0;
if (s.Length > 6)
sb.Append (s.Substring (7));
#endif
}
示例3: AppendItemWithInvalidBooleanAttribute
public void AppendItemWithInvalidBooleanAttribute()
{
Assert.Throws<ArgumentException>(() =>
{
// Construct the task item.
TaskItem i = new TaskItem();
i.ItemSpec = "MyResource.bmp";
i.SetMetadata("Name", "Kenny");
i.SetMetadata("Private", "Yes"); // This is our flag.
CommandLineBuilderExtension c = new CommandLineBuilderExtension();
// Validate that a legitimate bool works first.
try
{
c.AppendSwitchIfNotNull
(
"/myswitch:",
new ITaskItem[] { i },
new string[] { "Name", "Private" },
new bool[] { false, true }
);
Assert.Equal(@"/myswitch:MyResource.bmp,Kenny,Private", c.ToString());
}
catch (ArgumentException e)
{
Assert.True(false, "Got an unexpected exception:" + e.Message);
}
// Now try a bogus boolean.
i.SetMetadata("Private", "Maybe"); // This is our flag.
c.AppendSwitchIfNotNull
(
"/myswitch:",
new ITaskItem[] { i },
new string[] { "Name", "Private" },
new bool[] { false, true }
); // <-- Expect an ArgumentException here.
}
);
}
示例4: TestWin32Resource
public void TestWin32Resource ()
{
MCExtended mc = new MCExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
mc.Win32Resource = "A;B";
mc.ARFC (c1);
mc.ACLC (c2);
Assert.AreEqual (String.Empty, c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例5: TestTreatWarningsAsErrors2
public void TestTreatWarningsAsErrors2 ()
{
MCExtended mc = new MCExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
mc.TreatWarningsAsErrors = false;
mc.ARFC (c1);
mc.ACLC (c2);
Assert.AreEqual ("/warnaserror-", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例6: TestSources
public void TestSources ()
{
MCExtended mc = new MCExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
mc.Sources = new ITaskItem [2] { new TaskItem ("A"), new TaskItem ("B") };
mc.ARFC (c1);
mc.ACLC (c2);
Assert.AreEqual ("/out:A.exe A B", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例7: TestOptimize2
public void TestOptimize2 ()
{
MCExtended mc = new MCExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
mc.Optimize = false;
mc.ARFC (c1);
mc.ACLC (c2);
Assert.AreEqual ("/optimize-", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例8: TestMainEntryPoint
public void TestMainEntryPoint ()
{
MCExtended mc = new MCExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
mc.MainEntryPoint = "A";
mc.ARFC (c1);
mc.ACLC (c2);
Assert.AreEqual (String.Empty, c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例9: TestKeyContainer
public void TestKeyContainer ()
{
MCExtended mc = new MCExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
mc.KeyContainer = "A";
mc.ARFC (c1);
mc.ACLC (c2);
Assert.AreEqual ("/keycontainer:A", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例10: TestReferences
public void TestReferences ()
{
CscExtended csc = new CscExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
csc.References = new ITaskItem [2] { new TaskItem ("A;C"), new TaskItem ("B") };
csc.ARFC (c1);
csc.ACLC (c2);
Assert.AreEqual ("/reference:\"A;C\" /reference:B", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例11: TestMainEntryPoint
public void TestMainEntryPoint ()
{
CscExtended csc = new CscExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
csc.MainEntryPoint = "A;B";
csc.ARFC (c1);
csc.ACLC (c2);
Assert.AreEqual ("/main:\"A;B\"", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例12: TestDefineConstants2
public void TestDefineConstants2 ()
{
CscExtended csc = new CscExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
csc.DefineConstants = ";;;";
csc.ARFC (c1);
csc.ACLC (c2);
Assert.AreEqual (String.Empty, c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例13: TestDefineConstants
public void TestDefineConstants ()
{
CscExtended csc = new CscExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
csc.DefineConstants = "A;B;;CD;;;Foo Bar";
csc.ARFC (c1);
csc.ACLC (c2);
Assert.AreEqual ("/define:\"A;B;CD;Foo;Bar\"", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例14: TestAdditionalLibPaths
public void TestAdditionalLibPaths ()
{
CscExtended csc = new CscExtended ();
CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
csc.AdditionalLibPaths = new string [2] { "A'Foo", "B" };
csc.ARFC (c1);
csc.ACLC (c2);
Assert.AreEqual ("/lib:\"A'Foo\",B", c1.ToString (), "A1");
Assert.AreEqual (String.Empty, c2.ToString (), "A2");
}
示例15: TestWarningNotAsErrors
public void TestWarningNotAsErrors ()
{
CscExtended csc = new CscExtended ();
CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
csc.WarningsNotAsErrors = "A'B";
csc.ARFC (clbe);
Assert.AreEqual ("/warnaserror-:\"A'B\"", clbe.ToString (), "A1");
}