[xbuild] Fix 635767. Support enums for task property Outputs.
authorAnkit Jain <radical@corewars.org>
Tue, 31 Aug 2010 11:38:55 +0000 (17:08 +0530)
committerAnkit Jain <radical@corewars.org>
Tue, 31 Aug 2010 11:43:20 +0000 (17:13 +0530)
Add support for task properties to be enums, when publishing
Output.

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeType.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs

index bf2974593c5a26bb360e385be3994eedf9b9caf6..fe77ec59ac185006b6e30903593f295f5ab2ca44 100644 (file)
@@ -52,10 +52,11 @@ namespace Microsoft.Build.BuildEngine {
                                 type == typeof (uint) ||
                                 type == typeof (float) ||
                                 type == typeof (double) ||
-                                type == typeof (DateTime)) {
+                                type == typeof (DateTime) ||
+                                type.IsEnum)
                                output = o.ToString ();
-
-                       }
+                       else
+                               throw new Exception (String.Format ("Unsupported type : {0}", type));
                        return output;
                }
 
index 696ffbeedfbf9f646935fad6697756a372835d2b..e0ddc933326f20b74995ee09c666c0b8eecc7d9a 100644 (file)
@@ -198,7 +198,14 @@ namespace Microsoft.Build.BuildEngine {
                                              object o,
                                              string propertyName)
                {
-                       BuildProperty bp = ChangeType.ToBuildProperty (o, propertyInfo.PropertyType, propertyName);
+                       BuildProperty bp;
+                       try {
+                               bp = ChangeType.ToBuildProperty (o, propertyInfo.PropertyType, propertyName);
+                       } catch (Exception e) {
+                               throw new Exception (String.Format ("Error publishing Output from task property '{0} {1}' to property named '{2}' : {3}",
+                                                       propertyInfo.PropertyType, propertyInfo.Name, propertyName, e.Message),
+                                                       e);
+                       }
                        parentProject.EvaluatedProperties.AddProperty (bp);
                }
 
@@ -207,7 +214,15 @@ namespace Microsoft.Build.BuildEngine {
                                               object o,
                                               string itemName)
                {
-                       BuildItemGroup newItems = ChangeType.ToBuildItemGroup (o, propertyInfo.PropertyType, itemName);
+                       BuildItemGroup newItems;
+                       try {
+                               newItems = ChangeType.ToBuildItemGroup (o, propertyInfo.PropertyType, itemName);
+                       } catch (Exception e) {
+                               throw new Exception (String.Format ("Error publishing Output from task property '{0} {1}' to item named '{2}' : {3}",
+                                                       propertyInfo.PropertyType, propertyInfo.Name, itemName, e.Message),
+                                                       e);
+                       }
+
                        newItems.ParentProject = parentProject;
                        
                        if (parentProject.EvaluatedItemsByName.ContainsKey (itemName)) {