Skip to content

Commit

Permalink
Use more modern C# syntax in a few places
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainSwag101 committed Jul 2, 2023
1 parent 35583ab commit 521ba43
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions PS2PatchElf/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class Program
{
static void Main(string[] args)
{
// PS2PatchElf by CaptainSwag101
if (args.Length < 2 || args.Length > 3)
if (args.Length is not 2 or 3)
{
Console.WriteLine("Improper number of arguments specified.\nPlease pass an input ELF/SLUS, a PNACH file, and optionally the patched ELF/SLUS's output path, in that order!");
return;
Expand All @@ -19,7 +18,7 @@ static void Main(string[] args)
Elf? originalElf = ElfUtils.ParseElf(args[0]);

// Final catch-all sanity check to ensure the ELF/SLUS file is valid
if (originalElf == null)
if (originalElf is null)
{
Console.WriteLine("Something went wrong while loading the ELF file.");
return;
Expand Down
2 changes: 1 addition & 1 deletion PS2PatchLib/ElfUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static class ElfUtils
elf.SectionHeaders = new List<Elf.SectionHeader>();
for (int sh = 0; sh < elf.Header.SHNum; ++sh)
{

// We ignore these, I don't think they are necessary for PS2 ELF patching.
}

return elf;
Expand Down
2 changes: 1 addition & 1 deletion PS2PatchLib/PnachUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static List<PnachCheat> ParseCheatFile(string pnachPath)

using StreamReader reader = new(pnachPath);
string? line;
while ((line = reader.ReadLine()?.ToLowerInvariant()) != null)
while ((line = reader.ReadLine()?.ToLowerInvariant()) is not null)
{
// We only care about cheat lines
if (!line.StartsWith("patch"))
Expand Down

0 comments on commit 521ba43

Please sign in to comment.