mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Fix broken Mono after #268
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WTF/@EntryIndexedValue">WTF</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XML/@EntryIndexedValue">XML</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="_" Suffix="" Style="AaBb" /><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="_" Suffix="" Style="AaBb" /><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -117,7 +117,7 @@
|
||||
<Compile Include="JSON\Steam.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
<Compile Include="MobileAuthenticator.cs" />
|
||||
<Compile Include="Mono.cs" />
|
||||
<Compile Include="Runtime.cs" />
|
||||
<Compile Include="ObsoleteSteamGuardAccount.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace ArchiSteamFarm {
|
||||
globalConfig.FarmingDelay = DefaultFarmingDelay;
|
||||
}
|
||||
|
||||
if ((globalConfig.FarmingDelay > 5) && Mono.RequiresWorkaroundForBug41701()) {
|
||||
if ((globalConfig.FarmingDelay > 5) && Runtime.RequiresWorkaroundForMonoBug41701()) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace ArchiSteamFarm {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (GlobalConfig.Headless || !Environment.UserInteractive) {
|
||||
if (GlobalConfig.Headless || !Runtime.IsUserInteractive) {
|
||||
Logging.LogGenericWarning("Received a request for user input, but process is running in headless mode!");
|
||||
return null;
|
||||
}
|
||||
@@ -540,7 +540,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
private static void Main(string[] args) {
|
||||
if (Environment.UserInteractive) {
|
||||
if (Runtime.IsUserInteractive) {
|
||||
// App
|
||||
Init(args);
|
||||
|
||||
|
||||
@@ -23,27 +23,60 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
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) {
|
||||
internal static class Runtime {
|
||||
private static readonly Type MonoRuntime = Type.GetType("Mono.Runtime");
|
||||
private static bool IsRunningOnMono => MonoRuntime != null;
|
||||
|
||||
private static bool? _IsUserInteractive;
|
||||
internal static bool IsUserInteractive {
|
||||
get {
|
||||
if (_IsUserInteractive.HasValue) {
|
||||
return _IsUserInteractive.Value;
|
||||
}
|
||||
|
||||
if (Environment.UserInteractive) {
|
||||
_IsUserInteractive = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// If it's non-Mono, we can trust the result
|
||||
if (!IsRunningOnMono) {
|
||||
_IsUserInteractive = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise use workaround for Mono, as Environment.UserInteractive is always false
|
||||
// Please close your eyes, there is really no better way for now
|
||||
_IsUserInteractive = Console.In is StreamReader;
|
||||
return _IsUserInteractive.Value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool RequiresWorkaroundForMonoBug41701() {
|
||||
// Mono only, https://bugzilla.xamarin.com/show_bug.cgi?id=41701
|
||||
if (!IsRunningOnMono) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return version >= new Version(4, 4);
|
||||
Version monoVersion = GetMonoVersion();
|
||||
if (monoVersion == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return monoVersion >= new Version(4, 4);
|
||||
}
|
||||
|
||||
private static Version GetMonoVersion() {
|
||||
Type type = Type.GetType("Mono.Runtime");
|
||||
if (type == null) {
|
||||
return null; // OK, not Mono
|
||||
if (MonoRuntime == null) {
|
||||
Logging.LogNullError(nameof(MonoRuntime));
|
||||
return null;
|
||||
}
|
||||
|
||||
MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
MethodInfo displayName = MonoRuntime.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (displayName == null) {
|
||||
Logging.LogNullError(nameof(displayName));
|
||||
return null;
|
||||
Reference in New Issue
Block a user