diff --git a/ICD.Common.Utils/Extensions/AssemblyExtensions.cs b/ICD.Common.Utils/Extensions/AssemblyExtensions.cs index 4f87c1c..cfda1ff 100644 --- a/ICD.Common.Utils/Extensions/AssemblyExtensions.cs +++ b/ICD.Common.Utils/Extensions/AssemblyExtensions.cs @@ -29,17 +29,16 @@ namespace ICD.Common.Utils.Extensions #endif .CodeBase; - if (string.IsNullOrEmpty(path)) - { #if STANDARD + if (string.IsNullOrEmpty(path)) path = extends.Location; #endif - } - else + + const string prefix = @"file:/"; + if (path != null && path.StartsWith(prefix)) { - const string prefix = @"file:///"; - if (path.StartsWith(prefix)) - path = path.Substring(prefix.Length); + Uri uri = new Uri(path); + path = uri.LocalPath; } return IcdFile.Exists(path) ? path : null; diff --git a/ICD.Common.Utils/IO/IcdFile.cs b/ICD.Common.Utils/IO/IcdFile.cs index 11d3151..14c997e 100644 --- a/ICD.Common.Utils/IO/IcdFile.cs +++ b/ICD.Common.Utils/IO/IcdFile.cs @@ -12,7 +12,7 @@ namespace ICD.Common.Utils.IO public static class IcdFile { [PublicAPI] - public static string ReadToEnd(string path, Encoding encoding) + public static string ReadToEnd([NotNull] string path, [NotNull] Encoding encoding) { if (path == null) throw new ArgumentNullException("path"); @@ -28,7 +28,7 @@ namespace ICD.Common.Utils.IO } [PublicAPI] - public static DateTime GetLastWriteTime(string path) + public static DateTime GetLastWriteTime([NotNull] string path) { if (path == null) throw new ArgumentNullException("path"); @@ -37,10 +37,11 @@ namespace ICD.Common.Utils.IO } [PublicAPI] - public static bool Exists(string path) + public static bool Exists([CanBeNull] string path) { + // Consistent with Net Standard if (path == null) - throw new ArgumentNullException("path"); + return false; try { @@ -54,7 +55,7 @@ namespace ICD.Common.Utils.IO } [PublicAPI] - public static void Copy(string pathFrom, string pathTo) + public static void Copy([NotNull] string pathFrom, [NotNull] string pathTo) { if (pathFrom == null) throw new ArgumentNullException("pathFrom"); @@ -66,7 +67,7 @@ namespace ICD.Common.Utils.IO } [PublicAPI] - public static void Delete(string path) + public static void Delete([NotNull] string path) { if (path == null) throw new ArgumentNullException("path"); diff --git a/ICD.Common.Utils/IO/IcdPath.cs b/ICD.Common.Utils/IO/IcdPath.cs index ec7a9b7..7a65254 100644 --- a/ICD.Common.Utils/IO/IcdPath.cs +++ b/ICD.Common.Utils/IO/IcdPath.cs @@ -15,7 +15,7 @@ namespace ICD.Common.Utils.IO public static char AltDirectorySeparatorChar { get { return Path.AltDirectorySeparatorChar; } } - public static string GetFileName(string path) + public static string GetFileName([NotNull] string path) { if (path == null) throw new ArgumentNullException("path"); @@ -23,7 +23,7 @@ namespace ICD.Common.Utils.IO return Path.GetFileName(path); } - public static string GetFileNameWithoutExtension(string path) + public static string GetFileNameWithoutExtension([NotNull] string path) { if (path == null) throw new ArgumentNullException("path"); @@ -32,7 +32,7 @@ namespace ICD.Common.Utils.IO } [CanBeNull] - public static string GetDirectoryName(string path) + public static string GetDirectoryName([NotNull] string path) { if (path == null) throw new ArgumentNullException("path"); @@ -40,7 +40,7 @@ namespace ICD.Common.Utils.IO return Path.GetDirectoryName(path); } - public static string GetExtension(string path) + public static string GetExtension([NotNull] string path) { if (path == null) throw new ArgumentNullException("path"); @@ -48,7 +48,7 @@ namespace ICD.Common.Utils.IO return Path.GetExtension(path); } - public static string Combine(string a, string b) + public static string Combine([NotNull] string a, [NotNull] string b) { if (a == null) throw new ArgumentNullException("a"); @@ -59,7 +59,7 @@ namespace ICD.Common.Utils.IO return Path.Combine(a, b); } - public static string ChangeExtension(string path, string ext) + public static string ChangeExtension([NotNull] string path, [NotNull] string ext) { if (path == null) throw new ArgumentNullException("path");