Merge pull request #485 from mtausig/master
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / ConditionFactorExpresion.cs
index 323d99bc4475fd82e398ba8d85d0391b191ffae9..709fedf1ce88f40e5419b637ed4a48a64a5458eb 100644 (file)
@@ -25,8 +25,6 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-#if NET_2_0
-
 using System;
 using System.Collections;
 using System.Collections.Specialized;
@@ -34,7 +32,7 @@ using System.Globalization;
 using System.Xml;
 
 namespace Microsoft.Build.BuildEngine {
-       internal class ConditionFactorExpression : ConditionExpression {
+       internal sealed class ConditionFactorExpression : ConditionExpression {
        
                readonly Token token;
                
@@ -77,7 +75,9 @@ namespace Microsoft.Build.BuildEngine {
                        else if (falseValues [evaluatedToken.Value] != null)
                                return false;
                        else
-                               throw new InvalidOperationException ();
+                               throw new ExpressionEvaluationException (
+                                               String.Format ("Expression \"{0}\" evaluated to \"{1}\" instead of a boolean value",
+                                                               token.Value, evaluatedToken.Value));
                }
                
                public override float NumberEvaluate (Project context)
@@ -118,13 +118,12 @@ namespace Microsoft.Build.BuildEngine {
                        return true;
                }
                
-               private static Token EvaluateToken (Token token, Project context)
+               // FIXME: in some situations items might not be allowed
+               static Token EvaluateToken (Token token, Project context)
                {
-                       OldExpression oe = new OldExpression (context);
-                       oe.ParseSource (token.Value);
-                       return new Token ((string) oe.ConvertTo (typeof (string)), token.Type);
+                       Expression oe = new Expression ();
+                       oe.Parse (token.Value, ParseOptions.AllowItemsMetadataAndSplit);
+                       return new Token ((string) oe.ConvertTo (context, typeof (string)), token.Type, token.Position);
                }
        }
 }
-
-#endif