From f0229545541ff81f3f591c0b11f57042e41cac34 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 19 Mar 2020 15:23:01 +1000 Subject: [PATCH] Fix nullability warnings in PathExtensions Definitely not happy with any of this --- BizHawk.Common/Extensions/PathExtensions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BizHawk.Common/Extensions/PathExtensions.cs b/BizHawk.Common/Extensions/PathExtensions.cs index 1d4fcbbb2a..df105f3939 100644 --- a/BizHawk.Common/Extensions/PathExtensions.cs +++ b/BizHawk.Common/Extensions/PathExtensions.cs @@ -78,6 +78,7 @@ namespace BizHawk.Common.PathExtensions // zero 06-nov-2015 - regarding the below, i changed my mind. for libretro i want subdirectories here. var filesystemDir = Path.GetDirectoryName(filesystemSafeName); + if (string.IsNullOrEmpty(filesystemDir)) throw new Exception(); filesystemSafeName = Path.GetFileName(filesystemSafeName); filesystemSafeName = filesystemSafeName.RemoveInvalidFileSystemChars(); @@ -114,7 +115,8 @@ namespace BizHawk.Common.PathExtensions { public static string GetExeDirectoryAbsolute() { - var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + var path = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); + if (string.IsNullOrEmpty(path)) throw new Exception(); if (path.EndsWith(Path.DirectorySeparatorChar.ToString())) { path = path.Remove(path.Length - 1, 1);