mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-19 15:58:39 +00:00
Code cleanup
This commit is contained in:
@@ -212,3 +212,16 @@ dotnet_style_qualification_for_property = false:warning
|
|||||||
|
|
||||||
dotnet_style_readonly_field = true:warning
|
dotnet_style_readonly_field = true:warning
|
||||||
dotnet_style_require_accessibility_modifiers = always:warning
|
dotnet_style_require_accessibility_modifiers = always:warning
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Jetbrains / IntelliJ #
|
||||||
|
###############################
|
||||||
|
|
||||||
|
[*.{csproj,props,xml}]
|
||||||
|
ij_xml_keep_blank_lines = 1
|
||||||
|
ij_xml_keep_line_breaks = false
|
||||||
|
ij_xml_keep_line_breaks_in_text = false
|
||||||
|
ij_xml_space_inside_empty_tag = true
|
||||||
|
|
||||||
|
[*.{json,json5}]
|
||||||
|
ij_json_keep_line_breaks = false
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotS
|
|||||||
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, ArchiSteamFarm.Localization.Strings.WarningFailedWithError, response.StatusCode));
|
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, ArchiSteamFarm.Localization.Strings.WarningFailedWithError, response.StatusCode));
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
if (response.StatusCode == (HttpStatusCode) 429) {
|
if (response.StatusCode == (HttpStatusCode) 429) {
|
||||||
#else
|
#else
|
||||||
if (response.StatusCode == HttpStatusCode.TooManyRequests) {
|
if (response.StatusCode == HttpStatusCode.TooManyRequests) {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ internal static class Debugging {
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
internal static bool IsDebugBuild => true;
|
internal static bool IsDebugBuild => true;
|
||||||
#else
|
#else
|
||||||
internal static bool IsDebugBuild => false;
|
internal static bool IsDebugBuild => false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
internal static bool IsDebugConfigured => ASF.GlobalConfig?.Debug ?? throw new InvalidOperationException(nameof(ASF.GlobalConfig));
|
internal static bool IsDebugConfigured => ASF.GlobalConfig?.Debug ?? throw new InvalidOperationException(nameof(ASF.GlobalConfig));
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ internal static class OS {
|
|||||||
|
|
||||||
internal static DateTime ProcessStartTime {
|
internal static DateTime ProcessStartTime {
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
get => RuntimeMadness.ProcessStartTime.ToUniversalTime();
|
get => RuntimeMadness.ProcessStartTime.ToUniversalTime();
|
||||||
#else
|
#else
|
||||||
get {
|
get {
|
||||||
using Process process = Process.GetCurrentProcess();
|
using Process process = Process.GetCurrentProcess();
|
||||||
@@ -67,7 +67,7 @@ internal static class OS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
string runtime = RuntimeInformation.OSArchitecture.ToString();
|
string runtime = RuntimeInformation.OSArchitecture.ToString();
|
||||||
#else
|
#else
|
||||||
string runtime = RuntimeInformation.RuntimeIdentifier.Trim();
|
string runtime = RuntimeInformation.RuntimeIdentifier.Trim();
|
||||||
|
|
||||||
@@ -231,28 +231,28 @@ internal static class OS {
|
|||||||
|
|
||||||
internal static bool VerifyEnvironment() {
|
internal static bool VerifyEnvironment() {
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
// This is .NET Framework build, we support that one only on mono for platforms not supported by .NET Core
|
// This is .NET Framework build, we support that one only on mono for platforms not supported by .NET Core
|
||||||
|
|
||||||
// We're not going to analyze source builds, as we don't know what changes the author has made, assume they have a point
|
// We're not going to analyze source builds, as we don't know what changes the author has made, assume they have a point
|
||||||
if (SharedInfo.BuildInfo.IsCustomBuild) {
|
if (SharedInfo.BuildInfo.IsCustomBuild) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All windows variants have valid .NET Core build, and generic-netf is supported only on mono
|
// All windows variants have valid .NET Core build, and generic-netf is supported only on mono
|
||||||
if (OperatingSystem.IsWindows() || !RuntimeMadness.IsRunningOnMono) {
|
if (OperatingSystem.IsWindows() || !RuntimeMadness.IsRunningOnMono) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RuntimeInformation.OSArchitecture switch {
|
return RuntimeInformation.OSArchitecture switch {
|
||||||
// Sadly we can't tell a difference between ARMv6 and ARMv7 reliably, we'll believe that this linux-arm user knows what he's doing and he's indeed in need of generic-netf on ARMv6
|
// Sadly we can't tell a difference between ARMv6 and ARMv7 reliably, we'll believe that this linux-arm user knows what he's doing and he's indeed in need of generic-netf on ARMv6
|
||||||
Architecture.Arm => true,
|
Architecture.Arm => true,
|
||||||
|
|
||||||
// Apart from real x86, this also covers all unknown architectures, such as sparc, ppc64, and anything else Mono might support, we're fine with that
|
// Apart from real x86, this also covers all unknown architectures, such as sparc, ppc64, and anything else Mono might support, we're fine with that
|
||||||
Architecture.X86 => true,
|
Architecture.X86 => true,
|
||||||
|
|
||||||
// Everything else is covered by .NET Core
|
// Everything else is covered by .NET Core
|
||||||
_ => false
|
_ => false
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// This is .NET Core build, we support all scenarios
|
// This is .NET Core build, we support all scenarios
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public static class Utilities {
|
|||||||
CookieCollection cookies = cookieContainer.GetCookies(uri);
|
CookieCollection cookies = cookieContainer.GetCookies(uri);
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
return cookies.Count > 0 ? (from Cookie cookie in cookies where cookie.Name == name select cookie.Value).FirstOrDefault() : null;
|
return cookies.Count > 0 ? (from Cookie cookie in cookies where cookie.Name == name select cookie.Value).FirstOrDefault() : null;
|
||||||
#else
|
#else
|
||||||
return cookies.Count > 0 ? cookies.FirstOrDefault(cookie => cookie.Name == name)?.Value : null;
|
return cookies.Count > 0 ? cookies.FirstOrDefault(cookie => cookie.Name == name)?.Value : null;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ internal sealed class Startup {
|
|||||||
|
|
||||||
// Finally register proper API endpoints once we're done with routing
|
// Finally register proper API endpoints once we're done with routing
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
app.UseMvcWithDefaultRoute();
|
app.UseMvcWithDefaultRoute();
|
||||||
#else
|
#else
|
||||||
app.UseEndpoints(static endpoints => endpoints.MapControllers());
|
app.UseEndpoints(static endpoints => endpoints.MapControllers());
|
||||||
#endif
|
#endif
|
||||||
@@ -345,14 +345,14 @@ internal sealed class Startup {
|
|||||||
mvc.AddControllersAsServices();
|
mvc.AddControllersAsServices();
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
// Use latest compatibility version for MVC
|
// Use latest compatibility version for MVC
|
||||||
mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
|
mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
|
||||||
|
|
||||||
// Add standard formatters
|
// Add standard formatters
|
||||||
mvc.AddFormatterMappings();
|
mvc.AddFormatterMappings();
|
||||||
|
|
||||||
// Add API explorer for swagger
|
// Add API explorer for swagger
|
||||||
mvc.AddApiExplorer();
|
mvc.AddApiExplorer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mvc.AddNewtonsoftJson(
|
mvc.AddNewtonsoftJson(
|
||||||
@@ -365,8 +365,8 @@ internal sealed class Startup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
// .NET Framework serializes Version as object by default, serialize it as string just like .NET Core
|
// .NET Framework serializes Version as object by default, serialize it as string just like .NET Core
|
||||||
options.SerializerSettings.Converters.Add(new VersionConverter());
|
options.SerializerSettings.Converters.Add(new VersionConverter());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -36,38 +36,42 @@ namespace ArchiSteamFarm.IPC;
|
|||||||
|
|
||||||
internal static class WebUtilities {
|
internal static class WebUtilities {
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
internal static IMvcCoreBuilder AddControllers(this IServiceCollection services) {
|
internal static IMvcCoreBuilder AddControllers(this IServiceCollection services) {
|
||||||
if (services == null) {
|
if (services == null) {
|
||||||
throw new ArgumentNullException(nameof(services));
|
throw new ArgumentNullException(nameof(services));
|
||||||
}
|
|
||||||
|
|
||||||
return services.AddMvcCore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IMvcCoreBuilder AddNewtonsoftJson(this IMvcCoreBuilder mvc, Action<MvcJsonOptions> setupAction) {
|
return services.AddMvcCore();
|
||||||
if (mvc == null) {
|
}
|
||||||
throw new ArgumentNullException(nameof(mvc));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setupAction == null) {
|
internal static IMvcCoreBuilder AddNewtonsoftJson(this IMvcCoreBuilder mvc, Action<MvcJsonOptions> setupAction) {
|
||||||
throw new ArgumentNullException(nameof(setupAction));
|
if (mvc == null) {
|
||||||
}
|
throw new ArgumentNullException(nameof(mvc));
|
||||||
|
|
||||||
// Add JSON formatters that will be used as default ones if no specific formatters are asked for
|
|
||||||
mvc.AddJsonFormatters();
|
|
||||||
|
|
||||||
mvc.AddJsonOptions(setupAction);
|
|
||||||
|
|
||||||
return mvc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IServiceCollection AddRequestLocalization(this IServiceCollection services, Action<RequestLocalizationOptions> action) {
|
if (setupAction == null) {
|
||||||
if (services == null) {
|
throw new ArgumentNullException(nameof(setupAction));
|
||||||
throw new ArgumentNullException(nameof(services));
|
|
||||||
}
|
|
||||||
|
|
||||||
return services.Configure(action);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add JSON formatters that will be used as default ones if no specific formatters are asked for
|
||||||
|
mvc.AddJsonFormatters();
|
||||||
|
|
||||||
|
mvc.AddJsonOptions(setupAction);
|
||||||
|
|
||||||
|
return mvc;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static IServiceCollection AddRequestLocalization(this IServiceCollection services, Action<RequestLocalizationOptions> action) {
|
||||||
|
if (services == null) {
|
||||||
|
throw new ArgumentNullException(nameof(services));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action == null) {
|
||||||
|
throw new ArgumentNullException(nameof(action));
|
||||||
|
}
|
||||||
|
|
||||||
|
return services.Configure(action);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
internal static string? GetUnifiedName(this Type type) {
|
internal static string? GetUnifiedName(this Type type) {
|
||||||
|
|||||||
@@ -97,32 +97,32 @@ public static class SharedInfo {
|
|||||||
|
|
||||||
internal static class BuildInfo {
|
internal static class BuildInfo {
|
||||||
#if ASF_VARIANT_DOCKER
|
#if ASF_VARIANT_DOCKER
|
||||||
internal static bool CanUpdate => false;
|
internal static bool CanUpdate => false;
|
||||||
internal static string Variant => "docker";
|
internal static string Variant => "docker";
|
||||||
#elif ASF_VARIANT_GENERIC
|
#elif ASF_VARIANT_GENERIC
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "generic";
|
internal static string Variant => "generic";
|
||||||
#elif ASF_VARIANT_GENERIC_NETF
|
#elif ASF_VARIANT_GENERIC_NETF
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "generic-netf";
|
internal static string Variant => "generic-netf";
|
||||||
#elif ASF_VARIANT_LINUX_ARM
|
#elif ASF_VARIANT_LINUX_ARM
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "linux-arm";
|
internal static string Variant => "linux-arm";
|
||||||
#elif ASF_VARIANT_LINUX_ARM64
|
#elif ASF_VARIANT_LINUX_ARM64
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "linux-arm64";
|
internal static string Variant => "linux-arm64";
|
||||||
#elif ASF_VARIANT_LINUX_X64
|
#elif ASF_VARIANT_LINUX_X64
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "linux-x64";
|
internal static string Variant => "linux-x64";
|
||||||
#elif ASF_VARIANT_OSX_ARM64
|
#elif ASF_VARIANT_OSX_ARM64
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "osx-arm64";
|
internal static string Variant => "osx-arm64";
|
||||||
#elif ASF_VARIANT_OSX_X64
|
#elif ASF_VARIANT_OSX_X64
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "osx-x64";
|
internal static string Variant => "osx-x64";
|
||||||
#elif ASF_VARIANT_WIN_X64
|
#elif ASF_VARIANT_WIN_X64
|
||||||
internal static bool CanUpdate => true;
|
internal static bool CanUpdate => true;
|
||||||
internal static string Variant => "win-x64";
|
internal static string Variant => "win-x64";
|
||||||
#else
|
#else
|
||||||
internal static bool CanUpdate => false;
|
internal static bool CanUpdate => false;
|
||||||
internal static string Variant => SourceVariant;
|
internal static string Variant => SourceVariant;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
AllowAutoRedirect = false, // This must be false if we want to handle custom redirection schemes such as "steammobile://"
|
AllowAutoRedirect = false, // This must be false if we want to handle custom redirection schemes such as "steammobile://"
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
|
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
|
||||||
#else
|
#else
|
||||||
AutomaticDecompression = DecompressionMethods.All,
|
AutomaticDecompression = DecompressionMethods.All,
|
||||||
#endif
|
#endif
|
||||||
@@ -80,9 +80,9 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
if (!RuntimeMadness.IsRunningOnMono) {
|
if (!RuntimeMadness.IsRunningOnMono) {
|
||||||
HttpClientHandler.MaxConnectionsPerServer = MaxConnections;
|
HttpClientHandler.MaxConnectionsPerServer = MaxConnections;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
HttpClientHandler.MaxConnectionsPerServer = MaxConnections;
|
HttpClientHandler.MaxConnectionsPerServer = MaxConnections;
|
||||||
#endif
|
#endif
|
||||||
@@ -719,9 +719,9 @@ public sealed class WebBrowser : IDisposable {
|
|||||||
|
|
||||||
// Reuse ports if possible
|
// Reuse ports if possible
|
||||||
#if NETFRAMEWORK
|
#if NETFRAMEWORK
|
||||||
if (!RuntimeMadness.IsRunningOnMono) {
|
if (!RuntimeMadness.IsRunningOnMono) {
|
||||||
ServicePointManager.ReusePort = true;
|
ServicePointManager.ReusePort = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ServicePointManager.ReusePort = true;
|
ServicePointManager.ReusePort = true;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user