From d7b6f77abcc1763d37792980ef3e6374c3f53434 Mon Sep 17 00:00:00 2001 From: Tom van Dijck Date: Tue, 6 Sep 2016 11:47:18 -0700 Subject: [PATCH 1/2] fix switch/separator in rules_xml --- src/actions/vstudio/vs2010_rules_xml.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/actions/vstudio/vs2010_rules_xml.lua b/src/actions/vstudio/vs2010_rules_xml.lua index b5a56f7b92..639c0da3d0 100644 --- a/src/actions/vstudio/vs2010_rules_xml.lua +++ b/src/actions/vstudio/vs2010_rules_xml.lua @@ -146,7 +146,10 @@ function m.boolProperty(def) p.push('', def.switch or "[value]") + if def.switch then + p.w('Switch="%s"', def.switch) + end + p.w(' />') p.pop() end @@ -166,10 +169,13 @@ p.w('Name="%d"', key) if switches[key] then p.w('DisplayName="%s"', values[key]) - p.w('Switch="%s" />', switches[key]) + if switches[key] then + p.w('Switch="%s"', switches[key]) + end else p.w('DisplayName="%s" />', values[key]) end + p.w(' />') p.pop() end @@ -180,7 +186,10 @@ function m.stringProperty(def) p.push('', def.switch or "[value]") + if def.switch then + p.w('Switch="%s"', def.switch) + end + p.w(' />') p.pop() end @@ -188,8 +197,13 @@ function m.stringListProperty(def) p.push('', def.switch or "[value]") + if def.separator then + p.w('Separator="%s"', def.separator) + end + if def.switch then + p.w('Switch="%s"', def.switch) + end + p.w(' />') p.pop() end From 21631dd0e9ebfd2cb4716a39a191896f45ccec14 Mon Sep 17 00:00:00 2001 From: Tom van Dijck Date: Tue, 13 Jun 2017 12:11:54 -0700 Subject: [PATCH 2/2] Adding tests, and fixing a few typos. --- src/actions/vstudio/vs2010_rules_xml.lua | 10 +- .../actions/vstudio/vc2010/test_rule_xml.lua | 126 +++++++++++++++++- 2 files changed, 128 insertions(+), 8 deletions(-) diff --git a/src/actions/vstudio/vs2010_rules_xml.lua b/src/actions/vstudio/vs2010_rules_xml.lua index 639c0da3d0..372367f66c 100644 --- a/src/actions/vstudio/vs2010_rules_xml.lua +++ b/src/actions/vstudio/vs2010_rules_xml.lua @@ -149,7 +149,7 @@ if def.switch then p.w('Switch="%s"', def.switch) end - p.w(' />') + p.w('/>') p.pop() end @@ -173,9 +173,9 @@ p.w('Switch="%s"', switches[key]) end else - p.w('DisplayName="%s" />', values[key]) + p.w('DisplayName="%s"', values[key]) end - p.w(' />') + p.w('/>') p.pop() end @@ -189,7 +189,7 @@ if def.switch then p.w('Switch="%s"', def.switch) end - p.w(' />') + p.w('/>') p.pop() end @@ -203,7 +203,7 @@ if def.switch then p.w('Switch="%s"', def.switch) end - p.w(' />') + p.w('/>') p.pop() end diff --git a/tests/actions/vstudio/vc2010/test_rule_xml.lua b/tests/actions/vstudio/vc2010/test_rule_xml.lua index a47bb77f3f..a18fb07b49 100644 --- a/tests/actions/vstudio/vc2010/test_rule_xml.lua +++ b/tests/actions/vstudio/vc2010/test_rule_xml.lua @@ -34,7 +34,7 @@ -- Property definitions --- - function suite.properties_onString() + function suite.properties_onStringNoSwitch() createVar { name="MyVar", kind="string" } local r = test.getRule("MyRule") m.properties(r) @@ -43,7 +43,21 @@ Name="MyVar" HelpContext="0" DisplayName="MyVar" - Switch="[value]" /> + /> + ]] + end + + function suite.properties_onString() + createVar { name="MyVar", kind="string", switch="[value]" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + ]] end @@ -56,6 +70,112 @@ Name="MyVar" HelpContext="0" DisplayName="MyVar" - Switch="[value]" /> + /> + ]] + end + + + function suite.properties_onBooleanNoSwitch() + createVar { name="MyVar", kind="boolean" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + ]] + end + + function suite.properties_onBoolean() + createVar { name="MyVar", kind="boolean", switch="[value]" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + ]] + end + + function suite.properties_onEnum() + createVar { + name = "OptimizationLevel", + display = "Optimization Level", + values = { + [0] = "None", + [1] = "Size", + [2] = "Speed", + }, + switch = { + [0] = "-O0", + [1] = "-O1", + [2] = "-O3", + }, + value = 2, + } + + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + + + + + ]] + end + + function suite.properties_onEnumNoSwitches() + createVar { + name = "OptimizationLevel", + display = "Optimization Level", + values = { + [0] = "None", + [1] = "Size", + [2] = "Speed", + }, + value = 2, + } + + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + + + + ]] end