mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Disgusting fix for broken Mono
This commit is contained in:
@@ -109,6 +109,7 @@
|
||||
<Compile Include="JSON\GitHub.cs" />
|
||||
<Compile Include="JSON\Steam.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
<Compile Include="Mono.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Trading.cs" />
|
||||
|
||||
@@ -159,6 +159,11 @@ namespace ArchiSteamFarm {
|
||||
globalConfig.FarmingDelay = DefaultFarmingDelay;
|
||||
}
|
||||
|
||||
if ((globalConfig.FarmingDelay > 5) && Mono.RequiresWorkaroundForBug41701()) {
|
||||
Logging.LogGenericWarning("Your Mono runtime is affected by bug 41701, FarmingDelay of " + globalConfig.FarmingDelay + " is not possible - value of 5 will be used instead");
|
||||
globalConfig.FarmingDelay = 5;
|
||||
}
|
||||
|
||||
if (globalConfig.HttpTimeout == 0) {
|
||||
Logging.LogGenericWarning("Configured HttpTimeout is invalid: " + globalConfig.HttpTimeout + ". Value of " + DefaultHttpTimeout + " will be used instead");
|
||||
globalConfig.HttpTimeout = DefaultHttpTimeout;
|
||||
|
||||
51
ArchiSteamFarm/Mono.cs
Normal file
51
ArchiSteamFarm/Mono.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Mono {
|
||||
internal static bool RequiresWorkaroundForBug41701() {
|
||||
// https://bugzilla.xamarin.com/show_bug.cgi?id=41701
|
||||
Version version = GetMonoVersion();
|
||||
if (version == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return version >= new Version(4, 4);
|
||||
}
|
||||
|
||||
private static Version GetMonoVersion() {
|
||||
Type type = Type.GetType("Mono.Runtime");
|
||||
if (type == null) {
|
||||
return null; // OK, not Mono
|
||||
}
|
||||
|
||||
MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (displayName == null) {
|
||||
Logging.LogNullError(nameof(displayName));
|
||||
return null;
|
||||
}
|
||||
|
||||
string versionString = (string) displayName.Invoke(null, null);
|
||||
if (string.IsNullOrEmpty(versionString)) {
|
||||
Logging.LogNullError(nameof(versionString));
|
||||
return null;
|
||||
}
|
||||
|
||||
int index = versionString.IndexOf(' ');
|
||||
if (index <= 0) {
|
||||
Logging.LogNullError(nameof(index));
|
||||
return null;
|
||||
}
|
||||
|
||||
versionString = versionString.Substring(0, index);
|
||||
|
||||
Version version;
|
||||
if (Version.TryParse(versionString, out version)) {
|
||||
return version;
|
||||
}
|
||||
|
||||
Logging.LogNullError(nameof(version));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user