From 240f3594db6f633ece6818afd28dde1e1ef6b36c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 4 Oct 2018 13:33:08 -0700 Subject: Fix WixCop namespaces and some C# modernization --- src/wixcop/CommandLine/ConvertCommand.cs | 21 +++--- src/wixcop/CommandLine/HelpCommand.cs | 8 ++- src/wixcop/CommandLine/WixCopCommandLineParser.cs | 82 ++++++++++++----------- 3 files changed, 58 insertions(+), 53 deletions(-) (limited to 'src/wixcop/CommandLine') 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 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml; -using WixToolset.Extensibility.Data; -using WixToolset.Extensibility.Services; - -namespace WixCop.CommandLine +// 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. + +namespace WixToolset.Tools.WixCop.CommandLine { + using System; + using System.Collections.Generic; + using System.IO; + using System.Xml; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + internal class ConvertCommand : ICommandLineCommand { private const string SettingsFileDefault = "wixcop.settings.xml"; @@ -69,7 +70,7 @@ namespace WixCop.CommandLine var errors = this.InspectSubDirectories(converter, Path.GetFullPath(".")); - foreach (string searchPattern in this.SearchPatterns) + foreach (var searchPattern in this.SearchPatterns) { if (!this.SearchPatternResults.Contains(searchPattern)) { 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 @@ -using System; -using WixToolset.Extensibility.Data; +// 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. -namespace WixCop.CommandLine +namespace WixToolset.Tools.WixCop.CommandLine { + using System; + using WixToolset.Extensibility.Data; + internal class HelpCommand : ICommandLineCommand { 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 @@ -using System; -using System.Collections.Generic; -using WixCop.Interfaces; -using WixToolset.Core; -using WixToolset.Extensibility.Data; -using WixToolset.Extensibility.Services; +// 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. -namespace WixCop.CommandLine +namespace WixToolset.Tools.WixCop.CommandLine { + using System; + using System.Collections.Generic; + using WixToolset.Core; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + using WixToolset.Tools.WixCop.Interfaces; + public sealed class WixCopCommandLineParser : IWixCopCommandLineParser { private bool fixErrors; @@ -89,43 +91,43 @@ namespace WixCop.CommandLine switch (parameter.ToLowerInvariant()) { - case "?": - this.showHelp = true; - return true; - case "f": - this.fixErrors = true; - return true; - case "nologo": - this.showLogo = false; - return true; - case "s": - this.subDirectories = true; - return true; - default: // other parameters - if (parameter.StartsWith("set1", StringComparison.Ordinal)) - { - this.settingsFile1 = parameter.Substring(4); - } - else if (parameter.StartsWith("set2", StringComparison.Ordinal)) - { - this.settingsFile2 = parameter.Substring(4); - } - else if (parameter.StartsWith("indent:", StringComparison.Ordinal)) + case "?": + this.showHelp = true; + return true; + case "f": + this.fixErrors = true; + return true; + case "nologo": + this.showLogo = false; + return true; + case "s": + this.subDirectories = true; + return true; + default: // other parameters + if (parameter.StartsWith("set1", StringComparison.Ordinal)) + { + this.settingsFile1 = parameter.Substring(4); + } + else if (parameter.StartsWith("set2", StringComparison.Ordinal)) + { + this.settingsFile2 = parameter.Substring(4); + } + else if (parameter.StartsWith("indent:", StringComparison.Ordinal)) + { + try { - try - { - this.indentationAmount = Convert.ToInt32(parameter.Substring(7)); - } - catch - { - throw new ArgumentException("Invalid numeric argument.", parameter); - } + this.indentationAmount = Convert.ToInt32(parameter.Substring(7)); } - else + catch { - throw new ArgumentException("Invalid argument.", parameter); + throw new ArgumentException("Invalid numeric argument.", parameter); } - return true; + } + else + { + throw new ArgumentException("Invalid argument.", parameter); + } + return true; } } } -- cgit v1.2.3-55-g6feb