Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
striezel committed Oct 6, 2024
1 parent c090fc9 commit ccec62c
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 47 deletions.
4 changes: 2 additions & 2 deletions updater/ReturnCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License

namespace updater
{
public class ReturnCodes
public static class ReturnCodes
{
/// <summary>
/// return code that indicates successful program execution
Expand All @@ -32,7 +32,7 @@ public class ReturnCodes


/// <summary>
/// return code that identified unknown operation
/// return code that identifies unknown operation
/// </summary>
public const int rcUnknownOperation = 2;
} // class
Expand Down
1 change: 0 additions & 1 deletion updater/utility/Checksum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,5 @@ public static bool areEqual(string checksum1, string checksum2)
// Simple equality checks will do after normalisation.
return checksum1 == checksum2;
}

} // class
} // namespace
1 change: 0 additions & 1 deletion updater/utility/PortableExecutable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,5 @@ public static PEFormat determineFormat(string fileName)
return PEFormat.Unknown;
}
}

} // class
} // namespace
29 changes: 0 additions & 29 deletions updater/utility/Processes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,5 @@ private static int countAllByName(string name)
return -1;
}
}


/*
/// <summary>
/// Kills all processes with the given name.
/// </summary>
/// <param name="name">name of the process(es)</param>
/// <returns>Returns the number of killed processes in case of success.
/// Returns -1 in case of failure.</returns>
public static int killAllByName(string name)
{
int result = 0;
try
{
Process[] pProcess = Process.GetProcessesByName(name);
foreach (Process p in pProcess)
{
p.Kill();
p.WaitForExit();
result++;
} //foreach
} //try-c
catch
{
result = -1;
}
return result;
}
*/
} // class
} // namespace
1 change: 0 additions & 1 deletion updater/utility/Verificator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,5 @@ public static bool verifiyPublisher(string fileName, string publisher)
}
return sub == publisher;
}

}
} // namespace
1 change: 0 additions & 1 deletion updater/utility/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ public static string get()
ver.Minor.ToString().PadLeft(2, '0'),
ver.Build.ToString().PadLeft(2, '0')});
}

} // class
} // namespace
18 changes: 9 additions & 9 deletions updater/versions/Quartet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the updater command line interface.
Copyright (C) 2017, 2022 Dirk Stolle
Copyright (C) 2017, 2022, 2024 Dirk Stolle
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -73,55 +73,55 @@ public Quartet(string value)
/// Gets the full version.
/// </summary>
/// <returns>Returns a string containing the full version number.</returns>
public string full()
public readonly string full()
{
return major.ToString() + "." + minor.ToString() + "." +
patch.ToString() + "." + build.ToString();
}


public override string ToString()
public override readonly string ToString()
{
return full();
}


public bool Equals(Quartet other)
public readonly bool Equals(Quartet other)
{
return (major == other.major) && (minor == other.minor)
&& (patch == other.patch) && (build == other.build);
}


public bool Equals(ShrinkingQuartet other)
public readonly bool Equals(ShrinkingQuartet other)
{
return (major == other.major) && (minor == other.minor)
&& (patch == other.patch) && (build == other.build);
}


public bool Equals(ShrinkingDashedQuartet other)
public readonly bool Equals(ShrinkingDashedQuartet other)
{
return (major == other.major) && (minor == other.minor)
&& (patch == other.patch) && (build == other.build);
}


public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (obj is Quartet q)
return Equals(q);
return (obj is ShrinkingQuartet sq) && Equals(sq);
}


public override int GetHashCode()
public override readonly int GetHashCode()
{
return Convert.ToInt32((major ^ minor ^ patch ^ build) & 0x7FFFFFFFu);
}


public int CompareTo(Quartet other)
public readonly int CompareTo(Quartet other)
{
int c = major.CompareTo(other.major);
if (c != 0)
Expand Down
2 changes: 1 addition & 1 deletion updater/versions/ShrinkingDashedQuartet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ShrinkingDashedQuartet(string value)
/// Gets the full version.
/// </summary>
/// <returns>Returns a string containing the full version number.</returns>
public string full()
public readonly string full()
{
if (patch == 0)
return major.ToString() + "." + minor.ToString() + "-"
Expand Down
2 changes: 1 addition & 1 deletion updater/versions/ShrinkingQuartet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ShrinkingQuartet(string value)
/// Gets the full version.
/// </summary>
/// <returns>Returns a string containing the full version number.</returns>
public string full()
public readonly string full()
{
if (build != 0)
return major.ToString() + "." + minor.ToString() + "."
Expand Down
2 changes: 1 addition & 1 deletion updater/versions/Triple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Triple(string value)
/// Gets the full version.
/// </summary>
/// <returns>Returns a string containing the full version number.</returns>
public string full()
public readonly string full()
{
return major.ToString() + "." + minor.ToString() + "." +
patch.ToString();
Expand Down

0 comments on commit ccec62c

Please sign in to comment.