From 7d97850cb06f247dbdd330ad997a26aa48fc2abd Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 26 Sep 2023 15:31:43 -0400 Subject: [PATCH] Fix some more nullability warnings --- .../Protection/Macrovision.CDilla.cs | 6 ++- .../Macrovision.CactusDataShield.cs | 4 +- .../Protection/Macrovision.RipGuard.cs | 42 ++++++++++--------- .../Protection/Macrovision.SafeCast.cs | 6 ++- .../Protection/Macrovision.SafeDisc.cs | 6 ++- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs index 9f33682b..79251c21 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs @@ -156,7 +156,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 internal ConcurrentQueue CDillaCheckDirectoryPath(string path, IEnumerable files) +#else + internal ConcurrentQueue CDillaCheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { @@ -195,7 +199,7 @@ namespace BinaryObjectScanner.Protection new PathMatchSet(new PathMatch("CDILLA16.EXE", useEndsWith: true), "C-Dilla License Management System"), }; - return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); + return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs index d7b8277e..a6a8e03d 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs @@ -131,12 +131,12 @@ namespace BinaryObjectScanner.Protection #if NET48 public static string GetCactusDataShieldVersion(string firstMatchedString, IEnumerable files) #else - public static string? GetCactusDataShieldVersion(string firstMatchedString, IEnumerable? files) + public static string GetCactusDataShieldVersion(string firstMatchedString, IEnumerable? files) #endif { // If we have no files if (files == null) - return null; + return string.Empty; // Find the version.txt file first var versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase)); diff --git a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs index 6c41b07e..40184350 100644 --- a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs +++ b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs @@ -63,26 +63,10 @@ namespace BinaryObjectScanner.Protection } /// - internal ConcurrentQueue RipGuardCheckDirectoryPath(string path, IEnumerable files) - { - var matchers = new List - { - // Found in the Black Lagoon Season 1 DVD steelbook box set (Geneon ID 12970). - new PathMatchSet(new PathMatch("G23YHWO1.EXE", useEndsWith: true), "RipGuard"), - new PathMatchSet(new PathMatch("RGASDEV.SYS", useEndsWith: true), "RipGuard"), - - // Mentioned online in https://forum.redfox.bz/threads/resolved-one-on-one-with-tony-horton-vol2-disc3.33901/. - new PathMatchSet(new PathMatch("9KMJ9G4I.EXE", useEndsWith: true), "RipGuard (Unconfirmed - Please report to us on GitHub)"), - }; - - return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); - } - - /// #if NET48 - internal string RipGuardCheckFilePath(string path) + internal ConcurrentQueue RipGuardCheckDirectoryPath(string path, IEnumerable files) #else - internal string? RipGuardCheckFilePath(string path) + internal ConcurrentQueue RipGuardCheckDirectoryPath(string path, IEnumerable? files) #endif { var matchers = new List @@ -95,7 +79,27 @@ namespace BinaryObjectScanner.Protection new PathMatchSet(new PathMatch("9KMJ9G4I.EXE", useEndsWith: true), "RipGuard (Unconfirmed - Please report to us on GitHub)"), }; - return MatchUtil.GetFirstMatch(path, matchers, any: true); + return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false); } + + /// +#if NET48 + internal string RipGuardCheckFilePath(string path) +#else + internal string? RipGuardCheckFilePath(string path) +#endif + { + var matchers = new List + { + // Found in the Black Lagoon Season 1 DVD steelbook box set (Geneon ID 12970). + new PathMatchSet(new PathMatch("G23YHWO1.EXE", useEndsWith: true), "RipGuard"), + new PathMatchSet(new PathMatch("RGASDEV.SYS", useEndsWith: true), "RipGuard"), + + // Mentioned online in https://forum.redfox.bz/threads/resolved-one-on-one-with-tony-horton-vol2-disc3.33901/. + new PathMatchSet(new PathMatch("9KMJ9G4I.EXE", useEndsWith: true), "RipGuard (Unconfirmed - Please report to us on GitHub)"), + }; + + return MatchUtil.GetFirstMatch(path, matchers, any: true); } } +} diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs index 67e4d0c7..c57b62f6 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs @@ -152,7 +152,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 internal ConcurrentQueue SafeCastCheckDirectoryPath(string path, IEnumerable files) +#else + internal ConcurrentQueue SafeCastCheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { @@ -191,7 +195,7 @@ namespace BinaryObjectScanner.Protection new PathMatchSet(new PathMatch("CDAC13BA.EXE", useEndsWith: true), "SafeCast"), }; - return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); + return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false); } /// diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs index 91d6ca82..8c4ab0ee 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs @@ -114,7 +114,11 @@ namespace BinaryObjectScanner.Protection } /// +#if NET48 internal ConcurrentQueue SafeDiscCheckDirectoryPath(string path, IEnumerable files) +#else + internal ConcurrentQueue SafeDiscCheckDirectoryPath(string path, IEnumerable? files) +#endif { var matchers = new List { @@ -218,7 +222,7 @@ namespace BinaryObjectScanner.Protection new PathMatchSet(".SafeDiscDVD.bundle", "SafeDisc for Macintosh"), }; - return MatchUtil.GetAllMatches(files ?? System.Array.Empty(), matchers, any: false); + return MatchUtil.GetAllMatches(files ?? Array.Empty(), matchers, any: false); } ///