[msbuild] Implemented instance members on static property evaluation
authorMarek Safar <marek.safar@gmail.com>
Wed, 4 Jun 2014 09:23:13 +0000 (11:23 +0200)
committerMarek Safar <marek.safar@gmail.com>
Wed, 4 Jun 2014 09:25:23 +0000 (11:25 +0200)
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs
mcs/class/Microsoft.Build.Engine/Test/various/Properties.cs

index 1e0fda2fdd8b9b75617132da1f61dc8d8a09671b..655224f89a881be9a2e025a10d97ed6877a9b1f8 100644 (file)
@@ -528,6 +528,23 @@ namespace Microsoft.Build.BuildEngine {
                                        throw new InvalidProjectFileException (string.Format ("Invalid static method invocation syntax '{0}'", text.Substring (p)));
 
                                name = text.Substring (p, end - p);
+
+                               //
+                               // It can be instance member on static property
+                               //
+                               if (name.IndexOf ('.') > 0) {
+                                       var names = name.Split ('.');
+                                       int i;
+                                       for (i = 0; i < names.Length - 1; ++i) {
+                                               instance = new MemberInvocationReference (type, names [i]) {
+                                                       Instance = instance
+                                               };
+                                       }
+
+                                       type = null;
+                                       name = names [i];
+                               }
+
                                args = null;
                        }
 
index fba19683c18aeb799a09d5f4eaa23888737574e8..b45bc39228b76c25624bff1f50c16301f7438fd2 100644 (file)
@@ -160,6 +160,21 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
                        Assert.AreEqual (DateTime.Now.ToString ("yyyy.MM.dd"), proj.GetEvaluatedProperty ("Prop1"), "#1");
                }
 
+               [Test]
+               public void InstanceMemberOnStaticProperty ()
+               {
+                       string documentString = @"
+                                       <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                               <PropertyGroup>
+                                                       <Prop1>$([System.DateTime]::Now.Year)</Prop1>
+                                               </PropertyGroup>
+                                       </Project>
+                               ";
+
+                       proj.LoadXml (documentString);
+                       Assert.AreEqual (DateTime.Now.Year.ToString (), proj.GetEvaluatedProperty ("Prop1"), "#1");
+               }
+
                [Test]
                public void MSBuildPropertyFunctions ()
                {