diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-03-02 22:03:23 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-03-02 22:03:23 -0500 |
commit | 6f07801b047a4574445266de582b23cef815fe0e (patch) | |
tree | 01e09c5d41475c12a73de71c9a2e7348261ef882 /src | |
parent | 1485d98b24c7518b102102ef9790d88382c9863b (diff) | |
download | SMAPI-6f07801b047a4574445266de582b23cef815fe0e.tar.gz SMAPI-6f07801b047a4574445266de582b23cef815fe0e.tar.bz2 SMAPI-6f07801b047a4574445266de582b23cef815fe0e.zip |
only use WMI on Windows
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 20 | ||||
-rw-r--r-- | src/StardewModdingAPI/StardewModdingAPI.csproj | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 6ebeccd2..3e428eb0 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -4,10 +4,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; -using System.Management; using System.Reflection; using System.Threading; #if SMAPI_FOR_WINDOWS +using System.Management; using System.Windows.Forms; #endif using Microsoft.Xna.Framework.Graphics; @@ -586,19 +586,21 @@ namespace StardewModdingAPI } /// <summary>Get a human-readable name for the current platform.</summary> + [SuppressMessage("ReSharper", "EmptyGeneralCatchClause", Justification = "Error suppressed deliberately to fallback to default behaviour.")] private string GetFriendlyPlatformName() { +#if SMAPI_FOR_WINDOWS try { - return ( - from entry in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>() - select entry.GetPropertyValue("Caption").ToString() - ).FirstOrDefault(); - } - catch - { - return Environment.OSVersion.ToString(); + return new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem") + .Get() + .Cast<ManagementObject>() + .Select(entry => entry.GetPropertyValue("Caption").ToString()) + .FirstOrDefault(); } + catch { } +#endif + return Environment.OSVersion.ToString(); } } } diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj index 2340a431..4d782f56 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.csproj +++ b/src/StardewModdingAPI/StardewModdingAPI.csproj @@ -97,7 +97,7 @@ <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Drawing" /> - <Reference Include="System.Management" /> + <Reference Include="System.Management" Condition="$(OS) == 'Windows_NT'" /> <Reference Include="System.Numerics"> <Private>True</Private> </Reference> |