<PackageReference Include="NUnit" Version="4.3.0" />

AssemblyHelper

public static class AssemblyHelper
AssemblyHelper provides static methods for working with assemblies.
using System; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; namespace NUnit.Framework.Internal { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public static class AssemblyHelper { private static readonly string UriSchemeFile = Uri.UriSchemeFile; private static readonly string SchemeDelimiter = Uri.SchemeDelimiter; public static string GetAssemblyPath(Assembly assembly) { string codeBase = assembly.CodeBase; if (codeBase != null && IsFileUri(codeBase)) return GetAssemblyPathFromCodeBase(codeBase); return assembly.Location; } public static string GetDirectoryName(Assembly assembly) { return Path.GetDirectoryName(GetAssemblyPath(assembly)); } public static AssemblyName GetAssemblyName(Assembly assembly) { return assembly.GetName(); } public static Assembly Load(string nameOrPath) { string extension = Path.GetExtension(nameOrPath); if (extension.Equals(".dll", StringComparison.OrdinalIgnoreCase) || extension.Equals(".exe", StringComparison.OrdinalIgnoreCase)) return Assembly.Load(AssemblyName.GetAssemblyName(nameOrPath)); return Assembly.Load(nameOrPath); } private static bool IsFileUri(string uri) { return uri.StartsWith(UriSchemeFile, StringComparison.OrdinalIgnoreCase); } public static string GetAssemblyPathFromCodeBase(string codeBase) { int num = UriSchemeFile.Length + SchemeDelimiter.Length; if (codeBase[num] == '/') { if (codeBase[num + 2] == ':') num++; } else if (codeBase[num + 1] != ':') { num -= 2; } return codeBase.Substring(num); } } }