Skip to content

Commit

Permalink
Roslynator code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alchemistmatt committed Oct 7, 2021
1 parent 06d61f3 commit 5b89fb9
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ namespace VSProjNuGetVersionUpdater
/// It also updates packages.config files.
/// </summary>
/// <remarks>
/// <para>
/// Written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA)
///
/// </para>
/// <para>
/// E-mail: [email protected] or [email protected]
/// Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://panomics.pnnl.gov/ or https://www.pnnl.gov/integrative-omics
/// </para>
/// </remarks>
internal static class Program
{
public const string PROGRAM_DATE = "May 9, 2019";
public const string PROGRAM_DATE = "October 6, 2021";

private struct PackageUpdateOptions
{
Expand All @@ -48,8 +51,7 @@ private struct PackageUpdateOptions

private static bool mProgressNewlineRequired;


static int Main(string[] args)
private static int Main()
{
var commandLineParse = new clsParseCommandLine();

Expand All @@ -68,7 +70,6 @@ static int Main(string[] args)

try
{

var success = false;

if (commandLineParse.ParseCommandLine())
Expand All @@ -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");
Expand All @@ -114,7 +114,6 @@ static int Main(string[] args)
Console.WriteLine("Search complete");

Thread.Sleep(250);

}
catch (Exception ex)
{
Expand All @@ -124,7 +123,6 @@ static int Main(string[] args)
}

return 0;

}

private static bool IsUpdateRequired(string currentVersion, PackageUpdateOptions updateOptions, out Version parsedVersion)
Expand Down Expand Up @@ -272,7 +270,6 @@ private static void ProcessProjectFile(FileSystemInfo projectFile, string baseDi
var versionAttribute = packageRef.Attribute("Version");
if (versionAttribute != null)
{

// Found XML like this:
// <PackageReference Include="PRISM-Library" Version="2.4.93" />

Expand Down Expand Up @@ -315,7 +312,6 @@ private static void ShowUpdateInfo(PackageUpdateOptions updateOptions, Version p
/// <param name="xmlFile"></param>
private static void UpdateEmptyXMLTagFormatting(FileSystemInfo xmlFile)
{

try
{
// Reopen the file and add back line feeds to pairs of XML tags
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -419,7 +413,6 @@ private static bool SearchForProjectFiles(
bool recurse,
PackageUpdateOptions updateOptions)
{

try
{
var newPackageVersion = Version.Parse(updateOptions.NuGetPackageVersion);
Expand Down Expand Up @@ -474,7 +467,6 @@ private static bool SearchForProjectFiles(

try
{

var projectFiles = searchDirectory.GetFiles("*.csproj").ToList();
projectFiles.AddRange(searchDirectory.GetFiles("*.vbproj"));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -685,7 +676,6 @@ private static void ShowErrorMessage(string title, IEnumerable<string> errorMess

private static void ShowProcessingFileMessage(FileSystemInfo projectFile, string baseDirectoryPath)
{

string projectFilePath;

if (!string.IsNullOrWhiteSpace(baseDirectoryPath))
Expand Down Expand Up @@ -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);
}

}
}

0 comments on commit 5b89fb9

Please sign in to comment.