Merge pull request #901 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mcs / class / Microsoft.Build.Tasks / Test / Microsoft.Build.Tasks / CscTest.cs
index ba1dc3eb46d70e037ccbabb9a81bc33fc6133960..846f47e627f72d3274d70bbab043e857f63f38f5 100644 (file)
@@ -26,6 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 using System;
+using System.Reflection;
 using System.Collections;
 using Microsoft.Build.Framework;
 using Microsoft.Build.Utilities;
@@ -43,6 +44,20 @@ namespace MonoTests.Microsoft.Build.Tasks {
                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
                }
 
                public void ACLC (CommandLineBuilderExtension commandLine)
@@ -189,6 +204,18 @@ namespace MonoTests.Microsoft.Build.Tasks {
                        Assert.AreEqual ("/nowarn:A", clbe.ToString (), "A1");
                }
 
+               [Test]
+               public void TestDisabledWarningsComma ()
+               {
+                       CscExtended csc = new CscExtended ();
+                       CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
+
+                       csc.DisabledWarnings = "A, B";
+                       csc.ARFC (clbe);
+
+                       Assert.AreEqual ("/nowarn:A;B", clbe.ToString (), "A1");
+               }
+
                [Test]
                public void TestDocumentationFile ()
                {
@@ -341,6 +368,11 @@ namespace MonoTests.Microsoft.Build.Tasks {
                        Assert.AreEqual (String.Empty, c2.ToString (), "A2");
                }
 
+               // Behavior for this intentionally differs from .net .
+               // msbuild doesn't quote the define args, but we do
+               // that to make it easier to copy/paste and execute
+               // compiler command lines, helps in debugging.
+               [Category ("NotDotNet")]
                [Test]
                public void TestDefineConstants ()
                {
@@ -348,11 +380,26 @@ namespace MonoTests.Microsoft.Build.Tasks {
                        CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
                        CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
 
-                       csc.DefineConstants = "A;B";
+                       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");
+               }
+
+               [Test]
+               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 ("/define:A;B", c1.ToString (), "A1");
+                       Assert.AreEqual (String.Empty, c1.ToString (), "A1");
                        Assert.AreEqual (String.Empty, c2.ToString (), "A2");
                }