diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-07 02:33:23 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-07 02:33:23 -0400 |
commit | d706a25053cdc5d9f1ccc2c09dc3913f835c3f78 (patch) | |
tree | bb628c31b328e46d8aa7ae4c521f5f76bdfcbd38 /src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs | |
parent | 6b05296e71c32abd158f354eeeaf1e135e72e6e2 (diff) | |
download | SMAPI-d706a25053cdc5d9f1ccc2c09dc3913f835c3f78.tar.gz SMAPI-d706a25053cdc5d9f1ccc2c09dc3913f835c3f78.tar.bz2 SMAPI-d706a25053cdc5d9f1ccc2c09dc3913f835c3f78.zip |
enable nullable annotations for most of the SMAPI toolkit (#837)
Diffstat (limited to 'src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs')
-rw-r--r-- | src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs index 9998edec..6978567e 100644 --- a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs +++ b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; @@ -59,11 +57,13 @@ namespace StardewModdingAPI.Toolkit.Framework #if SMAPI_FOR_WINDOWS try { - return new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem") + string? result = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem") .Get() .Cast<ManagementObject>() .Select(entry => entry.GetPropertyValue("Caption").ToString()) .FirstOrDefault(); + + return result ?? "Windows"; } catch { } #endif @@ -137,7 +137,7 @@ namespace StardewModdingAPI.Toolkit.Framework buffer = Marshal.AllocHGlobal(8192); if (LowLevelEnvironmentUtility.uname(buffer) == 0) { - string os = Marshal.PtrToStringAnsi(buffer); + string? os = Marshal.PtrToStringAnsi(buffer); return os == "Darwin"; } return false; |