aboutsummaryrefslogtreecommitdiff
path: root/src/wixcop/CommandLine
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2018-10-04 13:33:08 -0700
committerBob Arnson <bob@firegiant.com>2018-10-04 18:20:52 -0400
commit240f3594db6f633ece6818afd28dde1e1ef6b36c (patch)
treeab75f516217afa280944b2198a42c69b9a1b9cc0 /src/wixcop/CommandLine
parent917bfd43985af3afaac0b3a1d97a89a58bde1f2f (diff)
downloadwix-240f3594db6f633ece6818afd28dde1e1ef6b36c.tar.gz
wix-240f3594db6f633ece6818afd28dde1e1ef6b36c.tar.bz2
wix-240f3594db6f633ece6818afd28dde1e1ef6b36c.zip
Fix WixCop namespaces and some C# modernization
Diffstat (limited to 'src/wixcop/CommandLine')
-rw-r--r--src/wixcop/CommandLine/ConvertCommand.cs21
-rw-r--r--src/wixcop/CommandLine/HelpCommand.cs8
-rw-r--r--src/wixcop/CommandLine/WixCopCommandLineParser.cs82
3 files changed, 58 insertions, 53 deletions
diff --git a/src/wixcop/CommandLine/ConvertCommand.cs b/src/wixcop/CommandLine/ConvertCommand.cs
index 6af7d4ca..ab7cd359 100644
--- a/src/wixcop/CommandLine/ConvertCommand.cs
+++ b/src/wixcop/CommandLine/ConvertCommand.cs
@@ -1,13 +1,14 @@
1using System; 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2using System.Collections.Generic; 2
3using System.IO; 3namespace WixToolset.Tools.WixCop.CommandLine
4using System.Linq;
5using System.Xml;
6using WixToolset.Extensibility.Data;
7using WixToolset.Extensibility.Services;
8
9namespace WixCop.CommandLine
10{ 4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using System.Xml;
9 using WixToolset.Extensibility.Data;
10 using WixToolset.Extensibility.Services;
11
11 internal class ConvertCommand : ICommandLineCommand 12 internal class ConvertCommand : ICommandLineCommand
12 { 13 {
13 private const string SettingsFileDefault = "wixcop.settings.xml"; 14 private const string SettingsFileDefault = "wixcop.settings.xml";
@@ -69,7 +70,7 @@ namespace WixCop.CommandLine
69 70
70 var errors = this.InspectSubDirectories(converter, Path.GetFullPath(".")); 71 var errors = this.InspectSubDirectories(converter, Path.GetFullPath("."));
71 72
72 foreach (string searchPattern in this.SearchPatterns) 73 foreach (var searchPattern in this.SearchPatterns)
73 { 74 {
74 if (!this.SearchPatternResults.Contains(searchPattern)) 75 if (!this.SearchPatternResults.Contains(searchPattern))
75 { 76 {
diff --git a/src/wixcop/CommandLine/HelpCommand.cs b/src/wixcop/CommandLine/HelpCommand.cs
index a75dac5c..bfb784b0 100644
--- a/src/wixcop/CommandLine/HelpCommand.cs
+++ b/src/wixcop/CommandLine/HelpCommand.cs
@@ -1,8 +1,10 @@
1using System; 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2using WixToolset.Extensibility.Data;
3 2
4namespace WixCop.CommandLine 3namespace WixToolset.Tools.WixCop.CommandLine
5{ 4{
5 using System;
6 using WixToolset.Extensibility.Data;
7
6 internal class HelpCommand : ICommandLineCommand 8 internal class HelpCommand : ICommandLineCommand
7 { 9 {
8 public int Execute() 10 public int Execute()
diff --git a/src/wixcop/CommandLine/WixCopCommandLineParser.cs b/src/wixcop/CommandLine/WixCopCommandLineParser.cs
index 53012cfd..ae826d4f 100644
--- a/src/wixcop/CommandLine/WixCopCommandLineParser.cs
+++ b/src/wixcop/CommandLine/WixCopCommandLineParser.cs
@@ -1,12 +1,14 @@
1using System; 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2using System.Collections.Generic;
3using WixCop.Interfaces;
4using WixToolset.Core;
5using WixToolset.Extensibility.Data;
6using WixToolset.Extensibility.Services;
7 2
8namespace WixCop.CommandLine 3namespace WixToolset.Tools.WixCop.CommandLine
9{ 4{
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Core;
8 using WixToolset.Extensibility.Data;
9 using WixToolset.Extensibility.Services;
10 using WixToolset.Tools.WixCop.Interfaces;
11
10 public sealed class WixCopCommandLineParser : IWixCopCommandLineParser 12 public sealed class WixCopCommandLineParser : IWixCopCommandLineParser
11 { 13 {
12 private bool fixErrors; 14 private bool fixErrors;
@@ -89,43 +91,43 @@ namespace WixCop.CommandLine
89 91
90 switch (parameter.ToLowerInvariant()) 92 switch (parameter.ToLowerInvariant())
91 { 93 {
92 case "?": 94 case "?":
93 this.showHelp = true; 95 this.showHelp = true;
94 return true; 96 return true;
95 case "f": 97 case "f":
96 this.fixErrors = true; 98 this.fixErrors = true;
97 return true; 99 return true;
98 case "nologo": 100 case "nologo":
99 this.showLogo = false; 101 this.showLogo = false;
100 return true; 102 return true;
101 case "s": 103 case "s":
102 this.subDirectories = true; 104 this.subDirectories = true;
103 return true; 105 return true;
104 default: // other parameters 106 default: // other parameters
105 if (parameter.StartsWith("set1", StringComparison.Ordinal)) 107 if (parameter.StartsWith("set1", StringComparison.Ordinal))
106 { 108 {
107 this.settingsFile1 = parameter.Substring(4); 109 this.settingsFile1 = parameter.Substring(4);
108 } 110 }
109 else if (parameter.StartsWith("set2", StringComparison.Ordinal)) 111 else if (parameter.StartsWith("set2", StringComparison.Ordinal))
110 { 112 {
111 this.settingsFile2 = parameter.Substring(4); 113 this.settingsFile2 = parameter.Substring(4);
112 } 114 }
113 else if (parameter.StartsWith("indent:", StringComparison.Ordinal)) 115 else if (parameter.StartsWith("indent:", StringComparison.Ordinal))
116 {
117 try
114 { 118 {
115 try 119 this.indentationAmount = Convert.ToInt32(parameter.Substring(7));
116 {
117 this.indentationAmount = Convert.ToInt32(parameter.Substring(7));
118 }
119 catch
120 {
121 throw new ArgumentException("Invalid numeric argument.", parameter);
122 }
123 } 120 }
124 else 121 catch
125 { 122 {
126 throw new ArgumentException("Invalid argument.", parameter); 123 throw new ArgumentException("Invalid numeric argument.", parameter);
127 } 124 }
128 return true; 125 }
126 else
127 {
128 throw new ArgumentException("Invalid argument.", parameter);
129 }
130 return true;
129 } 131 }
130 } 132 }
131 } 133 }