From 5b89fb933d84d3950c540616a493140ee7d6d13e Mon Sep 17 00:00:00 2001 From: alchemistmatt Date: Wed, 6 Oct 2021 18:05:27 -0700 Subject: [PATCH] Roslynator code cleanup --- Program.cs | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/Program.cs b/Program.cs index ee2b5d0..e25fcbd 100644 --- a/Program.cs +++ b/Program.cs @@ -18,14 +18,17 @@ namespace VSProjNuGetVersionUpdater /// It also updates packages.config files. /// /// + /// /// Written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) - /// + /// + /// /// E-mail: matthew.monroe@pnnl.gov or proteomics@pnnl.gov /// Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://panomics.pnnl.gov/ or https://www.pnnl.gov/integrative-omics + /// /// internal static class Program { - public const string PROGRAM_DATE = "May 9, 2019"; + public const string PROGRAM_DATE = "October 6, 2021"; private struct PackageUpdateOptions { @@ -48,8 +51,7 @@ private struct PackageUpdateOptions private static bool mProgressNewlineRequired; - - static int Main(string[] args) + private static int Main() { var commandLineParse = new clsParseCommandLine(); @@ -68,7 +70,6 @@ static int Main(string[] args) try { - var success = false; if (commandLineParse.ParseCommandLine()) @@ -89,7 +90,6 @@ static int Main(string[] args) mSearchDirectoryPath = "."; } - if (string.IsNullOrWhiteSpace(mUpdateOptions.NuGetPackageName)) { ShowErrorMessage("NuGet package must be defined using /P or /Package"); @@ -114,7 +114,6 @@ static int Main(string[] args) Console.WriteLine("Search complete"); Thread.Sleep(250); - } catch (Exception ex) { @@ -124,7 +123,6 @@ static int Main(string[] args) } return 0; - } private static bool IsUpdateRequired(string currentVersion, PackageUpdateOptions updateOptions, out Version parsedVersion) @@ -272,7 +270,6 @@ private static void ProcessProjectFile(FileSystemInfo projectFile, string baseDi var versionAttribute = packageRef.Attribute("Version"); if (versionAttribute != null) { - // Found XML like this: // @@ -315,7 +312,6 @@ private static void ShowUpdateInfo(PackageUpdateOptions updateOptions, Version p /// private static void UpdateEmptyXMLTagFormatting(FileSystemInfo xmlFile) { - try { // Reopen the file and add back line feeds to pairs of XML tags @@ -373,13 +369,11 @@ private static void UpdateEmptyXMLTagFormatting(FileSystemInfo xmlFile) { tempFile.Delete(); } - } catch (Exception ex) { ShowErrorMessage("Error updating XML tag formatting in file " + xmlFile.FullName + ": " + ex.Message); } - } private static bool UpdateVersionAttributeIfRequired(XAttribute versionAttribute, PackageUpdateOptions updateOptions) @@ -419,7 +413,6 @@ private static bool SearchForProjectFiles( bool recurse, PackageUpdateOptions updateOptions) { - try { var newPackageVersion = Version.Parse(updateOptions.NuGetPackageVersion); @@ -474,7 +467,6 @@ private static bool SearchForProjectFiles( try { - var projectFiles = searchDirectory.GetFiles("*.csproj").ToList(); projectFiles.AddRange(searchDirectory.GetFiles("*.vbproj")); @@ -619,7 +611,6 @@ private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine com mSearchDirectoryPath = commandLineParse.RetrieveNonSwitchParameter(0); } - if (commandLineParse.RetrieveValueForParameter("I", out var paramValue)) { mSearchDirectoryPath = string.Copy(paramValue); @@ -685,7 +676,6 @@ private static void ShowErrorMessage(string title, IEnumerable errorMess private static void ShowProcessingFileMessage(FileSystemInfo projectFile, string baseDirectoryPath) { - string projectFilePath; if (!string.IsNullOrWhiteSpace(baseDirectoryPath)) @@ -743,19 +733,16 @@ private static void ShowProgramHelp() // Delay for 750 msec in case the user double clicked this file from within Windows Explorer (or started the program via a shortcut) Thread.Sleep(750); - } catch (Exception ex) { Console.WriteLine("Error displaying the program syntax: " + ex.Message); } - } private static void ShowWarning(string message, int emptyLinesBeforeMessage = 1) { ConsoleMsgUtils.ShowWarningCustom(message, emptyLinesBeforeMessage); } - } }