fix: Fixed bad Assembly path handling on 4-series

This commit is contained in:
Chris Cameron
2020-10-28 11:00:28 -04:00
parent 4aa76bd647
commit 64cc662ee7
3 changed files with 19 additions and 19 deletions

View File

@@ -29,17 +29,16 @@ namespace ICD.Common.Utils.Extensions
#endif #endif
.CodeBase; .CodeBase;
if (string.IsNullOrEmpty(path))
{
#if STANDARD #if STANDARD
if (string.IsNullOrEmpty(path))
path = extends.Location; path = extends.Location;
#endif #endif
}
else const string prefix = @"file:/";
if (path != null && path.StartsWith(prefix))
{ {
const string prefix = @"file:///"; Uri uri = new Uri(path);
if (path.StartsWith(prefix)) path = uri.LocalPath;
path = path.Substring(prefix.Length);
} }
return IcdFile.Exists(path) ? path : null; return IcdFile.Exists(path) ? path : null;

View File

@@ -12,7 +12,7 @@ namespace ICD.Common.Utils.IO
public static class IcdFile public static class IcdFile
{ {
[PublicAPI] [PublicAPI]
public static string ReadToEnd(string path, Encoding encoding) public static string ReadToEnd([NotNull] string path, [NotNull] Encoding encoding)
{ {
if (path == null) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");
@@ -28,7 +28,7 @@ namespace ICD.Common.Utils.IO
} }
[PublicAPI] [PublicAPI]
public static DateTime GetLastWriteTime(string path) public static DateTime GetLastWriteTime([NotNull] string path)
{ {
if (path == null) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");
@@ -37,10 +37,11 @@ namespace ICD.Common.Utils.IO
} }
[PublicAPI] [PublicAPI]
public static bool Exists(string path) public static bool Exists([CanBeNull] string path)
{ {
// Consistent with Net Standard
if (path == null) if (path == null)
throw new ArgumentNullException("path"); return false;
try try
{ {
@@ -54,7 +55,7 @@ namespace ICD.Common.Utils.IO
} }
[PublicAPI] [PublicAPI]
public static void Copy(string pathFrom, string pathTo) public static void Copy([NotNull] string pathFrom, [NotNull] string pathTo)
{ {
if (pathFrom == null) if (pathFrom == null)
throw new ArgumentNullException("pathFrom"); throw new ArgumentNullException("pathFrom");
@@ -66,7 +67,7 @@ namespace ICD.Common.Utils.IO
} }
[PublicAPI] [PublicAPI]
public static void Delete(string path) public static void Delete([NotNull] string path)
{ {
if (path == null) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");

View File

@@ -15,7 +15,7 @@ namespace ICD.Common.Utils.IO
public static char AltDirectorySeparatorChar { get { return Path.AltDirectorySeparatorChar; } } public static char AltDirectorySeparatorChar { get { return Path.AltDirectorySeparatorChar; } }
public static string GetFileName(string path) public static string GetFileName([NotNull] string path)
{ {
if (path == null) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");
@@ -23,7 +23,7 @@ namespace ICD.Common.Utils.IO
return Path.GetFileName(path); return Path.GetFileName(path);
} }
public static string GetFileNameWithoutExtension(string path) public static string GetFileNameWithoutExtension([NotNull] string path)
{ {
if (path == null) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");
@@ -32,7 +32,7 @@ namespace ICD.Common.Utils.IO
} }
[CanBeNull] [CanBeNull]
public static string GetDirectoryName(string path) public static string GetDirectoryName([NotNull] string path)
{ {
if (path == null) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");
@@ -40,7 +40,7 @@ namespace ICD.Common.Utils.IO
return Path.GetDirectoryName(path); return Path.GetDirectoryName(path);
} }
public static string GetExtension(string path) public static string GetExtension([NotNull] string path)
{ {
if (path == null) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");
@@ -48,7 +48,7 @@ namespace ICD.Common.Utils.IO
return Path.GetExtension(path); 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) if (a == null)
throw new ArgumentNullException("a"); throw new ArgumentNullException("a");
@@ -59,7 +59,7 @@ namespace ICD.Common.Utils.IO
return Path.Combine(a, b); 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) if (path == null)
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");