diff --git a/src/Shared/NetCore.cs b/src/Shared/NetCore.cs index 4fac3bf0d..e876132be 100644 --- a/src/Shared/NetCore.cs +++ b/src/Shared/NetCore.cs @@ -6,10 +6,9 @@ public class NetCore public static string GetNetCoreVersion() { Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; - var assemblyCodeBase = assembly.CodeBase ?? throw new ArgumentNullException("assemblyCodeBase"); - string[] assemblyPath = assemblyCodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); + string[] assemblyPath = assembly!.CodeBase!.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); - if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) + if (netCoreAppIndex >= 0 && netCoreAppIndex < assemblyPath.Length - 2) return assemblyPath[netCoreAppIndex + 1]; throw new Exception("Unable to determine .NET Core version."); }