diff --git a/OpenRA.Game/FieldLoader.cs b/OpenRA.Game/FieldLoader.cs index 6a725c02c0..6130367e14 100644 --- a/OpenRA.Game/FieldLoader.cs +++ b/OpenRA.Game/FieldLoader.cs @@ -398,13 +398,13 @@ namespace OpenRA return InvalidValueAction(value, fieldType, fieldName); } - else if (fieldType == typeof(ConditionExpression)) + else if (fieldType == typeof(VariableExpression)) { if (value != null) { try { - return new ConditionExpression(value); + return new VariableExpression(value); } catch (InvalidDataException e) { diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 1cc6d5c814..c7425f7f6f 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -260,7 +260,7 @@ - + diff --git a/OpenRA.Game/Support/ConditionExpression.cs b/OpenRA.Game/Support/VariableExpression.cs similarity index 99% rename from OpenRA.Game/Support/ConditionExpression.cs rename to OpenRA.Game/Support/VariableExpression.cs index 03af2d6f47..d9d553cea6 100644 --- a/OpenRA.Game/Support/ConditionExpression.cs +++ b/OpenRA.Game/Support/VariableExpression.cs @@ -18,7 +18,7 @@ using Expressions = System.Linq.Expressions; namespace OpenRA.Support { - public class ConditionExpression + public class VariableExpression { public readonly string Expression; readonly HashSet variables = new HashSet(); @@ -525,7 +525,7 @@ namespace OpenRA.Support } } - public ConditionExpression(string expression) + public VariableExpression(string expression) { Expression = expression; var tokens = new List(); diff --git a/OpenRA.Mods.Common/Lint/LintExts.cs b/OpenRA.Mods.Common/Lint/LintExts.cs index a8b1ee57fa..c53e05a503 100644 --- a/OpenRA.Mods.Common/Lint/LintExts.cs +++ b/OpenRA.Mods.Common/Lint/LintExts.cs @@ -29,9 +29,9 @@ namespace OpenRA.Mods.Common.Lint if (typeof(IEnumerable).IsAssignableFrom(type)) return fieldInfo.GetValue(ruleInfo) as IEnumerable; - if (type == typeof(ConditionExpression)) + if (type == typeof(VariableExpression)) { - var expr = (ConditionExpression)fieldInfo.GetValue(ruleInfo); + var expr = (VariableExpression)fieldInfo.GetValue(ruleInfo); return expr != null ? expr.Variables : Enumerable.Empty(); } @@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Lint if (typeof(IEnumerable).IsAssignableFrom(type)) return (IEnumerable)propertyInfo.GetValue(ruleInfo); - if (type == typeof(ConditionExpression)) + if (type == typeof(VariableExpression)) { - var expr = (ConditionExpression)propertyInfo.GetValue(ruleInfo); + var expr = (VariableExpression)propertyInfo.GetValue(ruleInfo); return expr != null ? expr.Variables : Enumerable.Empty(); } diff --git a/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs b/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs index 3f197345b0..25cef9a099 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/ConditionalTrait.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits [ConsumedConditionReference] [Desc("Boolean expression defining the condition to enable this trait.")] - public readonly ConditionExpression RequiresCondition = null; + public readonly VariableExpression RequiresCondition = null; public abstract object Create(ActorInitializer init); diff --git a/OpenRA.Mods.Common/Traits/Pluggable.cs b/OpenRA.Mods.Common/Traits/Pluggable.cs index 16f23af230..751e86f56e 100644 --- a/OpenRA.Mods.Common/Traits/Pluggable.cs +++ b/OpenRA.Mods.Common/Traits/Pluggable.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Requirements for accepting a plug type.", "Key is the plug type that the requirements applies to.", "Value is the condition expression defining the requirements to place the plug.")] - public readonly Dictionary Requirements = new Dictionary(); + public readonly Dictionary Requirements = new Dictionary(); [GrantedConditionReference] public IEnumerable LinterConditions { get { return Conditions.Values; } } diff --git a/OpenRA.Test/OpenRA.Game/ConditionExpressionTest.cs b/OpenRA.Test/OpenRA.Game/VariableExpressionTest.cs similarity index 95% rename from OpenRA.Test/OpenRA.Game/ConditionExpressionTest.cs rename to OpenRA.Test/OpenRA.Game/VariableExpressionTest.cs index 14cb0475ee..afbf05f0a7 100644 --- a/OpenRA.Test/OpenRA.Game/ConditionExpressionTest.cs +++ b/OpenRA.Test/OpenRA.Game/VariableExpressionTest.cs @@ -19,7 +19,7 @@ using OpenRA.Support; namespace OpenRA.Test { [TestFixture] - public class ConditionExpressionTest + public class VariableExpressionTest { IReadOnlyDictionary testValues = new ReadOnlyDictionary(new Dictionary() { @@ -29,28 +29,28 @@ namespace OpenRA.Test void AssertFalse(string expression) { - Assert.False(new ConditionExpression(expression).Evaluate(testValues) > 0, expression); + Assert.False(new VariableExpression(expression).Evaluate(testValues) > 0, expression); } void AssertTrue(string expression) { - Assert.True(new ConditionExpression(expression).Evaluate(testValues) > 0, expression); + Assert.True(new VariableExpression(expression).Evaluate(testValues) > 0, expression); } void AssertValue(string expression, int value) { - Assert.AreEqual(value, new ConditionExpression(expression).Evaluate(testValues), expression); + Assert.AreEqual(value, new VariableExpression(expression).Evaluate(testValues), expression); } void AssertParseFailure(string expression) { - Assert.Throws(typeof(InvalidDataException), () => new ConditionExpression(expression).Evaluate(testValues), expression); + Assert.Throws(typeof(InvalidDataException), () => new VariableExpression(expression).Evaluate(testValues), expression); } void AssertParseFailure(string expression, string errorMessage) { var actualErrorMessage = Assert.Throws(typeof(InvalidDataException), - () => new ConditionExpression(expression).Evaluate(testValues), + () => new VariableExpression(expression).Evaluate(testValues), expression).Message; Assert.AreEqual(errorMessage, actualErrorMessage, expression + " ===> " + actualErrorMessage); } diff --git a/OpenRA.Test/OpenRA.Test.csproj b/OpenRA.Test/OpenRA.Test.csproj index b9df93b6ab..e451d7c9fd 100644 --- a/OpenRA.Test/OpenRA.Test.csproj +++ b/OpenRA.Test/OpenRA.Test.csproj @@ -55,7 +55,7 @@ - +