diff options
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> |