From ddf6d76bdf9553419baf170dbcc896dcb98776b1 Mon Sep 17 00:00:00 2001 From: Cameron Osborn Date: Tue, 20 Aug 2019 12:20:47 -0700 Subject: [PATCH 1/2] Use C#8 Bang operator to fix nullability --- src/Shared/NetCore.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Shared/NetCore.cs b/src/Shared/NetCore.cs index 4fac3bf0d..a4b25baed 100644 --- a/src/Shared/NetCore.cs +++ b/src/Shared/NetCore.cs @@ -6,8 +6,7 @@ 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) return assemblyPath[netCoreAppIndex + 1]; From f9a6e18ab5b8dacba352a8d5f1cc30ea0bb035e0 Mon Sep 17 00:00:00 2001 From: Cameron Osborn Date: Tue, 20 Aug 2019 12:25:25 -0700 Subject: [PATCH 2/2] Nix support edge case --- src/Shared/NetCore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/NetCore.cs b/src/Shared/NetCore.cs index a4b25baed..e876132be 100644 --- a/src/Shared/NetCore.cs +++ b/src/Shared/NetCore.cs @@ -8,7 +8,7 @@ public static string GetNetCoreVersion() Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; 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."); }