diff --git a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj
index d5ce83871..759c8bf96 100644
--- a/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj
+++ b/ArchiSteamFarm.CustomPlugins.ExamplePlugin/ArchiSteamFarm.CustomPlugins.ExamplePlugin.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/ArchiSteamFarm.CustomPlugins.PeriodicGC/ArchiSteamFarm.CustomPlugins.PeriodicGC.csproj b/ArchiSteamFarm.CustomPlugins.PeriodicGC/ArchiSteamFarm.CustomPlugins.PeriodicGC.csproj
index 7336522be..0d78c9416 100644
--- a/ArchiSteamFarm.CustomPlugins.PeriodicGC/ArchiSteamFarm.CustomPlugins.PeriodicGC.csproj
+++ b/ArchiSteamFarm.CustomPlugins.PeriodicGC/ArchiSteamFarm.CustomPlugins.PeriodicGC.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/ArchiSteamFarm.CustomPlugins.SignInWithSteam/ArchiSteamFarm.CustomPlugins.SignInWithSteam.csproj b/ArchiSteamFarm.CustomPlugins.SignInWithSteam/ArchiSteamFarm.CustomPlugins.SignInWithSteam.csproj
index 411f5e8ea..eed290f6d 100644
--- a/ArchiSteamFarm.CustomPlugins.SignInWithSteam/ArchiSteamFarm.CustomPlugins.SignInWithSteam.csproj
+++ b/ArchiSteamFarm.CustomPlugins.SignInWithSteam/ArchiSteamFarm.CustomPlugins.SignInWithSteam.csproj
@@ -11,11 +11,14 @@
-
+
+
+
+
diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/ArchiSteamFarm.OfficialPlugins.ItemsMatcher.csproj b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/ArchiSteamFarm.OfficialPlugins.ItemsMatcher.csproj
index a4c076c5b..06340d0b4 100644
--- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/ArchiSteamFarm.OfficialPlugins.ItemsMatcher.csproj
+++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/ArchiSteamFarm.OfficialPlugins.ItemsMatcher.csproj
@@ -13,10 +13,12 @@
-
+
+
+
diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs
index 340165b5c..a86856fc1 100644
--- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs
+++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs
@@ -366,7 +366,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
LastAnnouncement = DateTime.UtcNow.AddYears(1);
return;
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
case (HttpStatusCode) 429:
#else
case HttpStatusCode.TooManyRequests:
diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj
index 273c2a8b7..d196d6a70 100644
--- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj
+++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj
@@ -12,7 +12,7 @@
-
+
diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs
index a9968e918..5624d766d 100644
--- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs
+++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs
@@ -623,7 +623,7 @@ internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotC
GlobalCache.Reset(true);
break;
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
case (HttpStatusCode) 429:
#else
case HttpStatusCode.TooManyRequests:
diff --git a/ArchiSteamFarm.sln.DotSettings b/ArchiSteamFarm.sln.DotSettings
index edb4170f9..8e52893e7 100644
--- a/ArchiSteamFarm.sln.DotSettings
+++ b/ArchiSteamFarm.sln.DotSettings
@@ -241,7 +241,6 @@
SUGGESTION
WARNING
WARNING
- WARNING
WARNING
SUGGESTION
SUGGESTION
diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj
index df88a3dcb..e2717031a 100644
--- a/ArchiSteamFarm/ArchiSteamFarm.csproj
+++ b/ArchiSteamFarm/ArchiSteamFarm.csproj
@@ -29,7 +29,7 @@
-
+
@@ -39,10 +39,17 @@
+
+
+
+
+
+
+
diff --git a/ArchiSteamFarm/Core/ASF.cs b/ArchiSteamFarm/Core/ASF.cs
index e0033bb0f..0778f985e 100644
--- a/ArchiSteamFarm/Core/ASF.cs
+++ b/ArchiSteamFarm/Core/ASF.cs
@@ -1048,7 +1048,8 @@ public static class ASF {
return false;
}
- if (!Directory.Exists(directory)) {
+ // ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
+ if (!Directory.Exists(directory!)) {
// ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
Directory.CreateDirectory(directory!);
}
diff --git a/ArchiSteamFarm/Core/GeneratedRegexes.cs b/ArchiSteamFarm/Core/GeneratedRegexes.cs
index c9d679572..3ed1bb476 100644
--- a/ArchiSteamFarm/Core/GeneratedRegexes.cs
+++ b/ArchiSteamFarm/Core/GeneratedRegexes.cs
@@ -30,7 +30,7 @@ internal static partial class GeneratedRegexes {
private const string DigitsPattern = @"\d+";
private const string NonAsciiPattern = @"[^\u0000-\u007F]+";
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
internal static Regex CdKey() => new(CdKeyPattern, DefaultOptions);
internal static Regex Decimal() => new(DecimalPattern, DefaultOptions);
internal static Regex Digits() => new(DigitsPattern, DefaultOptions);
diff --git a/ArchiSteamFarm/Core/NativeMethods.cs b/ArchiSteamFarm/Core/NativeMethods.cs
index 6f2a41ecc..d8f08219b 100644
--- a/ArchiSteamFarm/Core/NativeMethods.cs
+++ b/ArchiSteamFarm/Core/NativeMethods.cs
@@ -26,48 +26,22 @@ using System.Runtime.Versioning;
namespace ArchiSteamFarm.Core;
internal static partial class NativeMethods {
- [SupportedOSPlatform("Windows")]
- internal const EExecutionState AwakeExecutionState = EExecutionState.SystemRequired | EExecutionState.AwayModeRequired | EExecutionState.Continuous;
-
- [SupportedOSPlatform("Windows")]
- internal const uint EnableQuickEditMode = 0x0040;
-
- [SupportedOSPlatform("Windows")]
- internal const byte ShowWindowMinimize = 6;
-
- [SupportedOSPlatform("Windows")]
- internal const sbyte StandardInputHandle = -10;
-
- [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
- [SupportedOSPlatform("FreeBSD")]
- [SupportedOSPlatform("Linux")]
- [SupportedOSPlatform("MacOS")]
-#if NETFRAMEWORK
-#pragma warning disable CA2101 // False positive, we can't use unicode charset on Unix, and it uses UTF-8 by default anyway
- [DllImport("libc", EntryPoint = "chmod", SetLastError = true)]
- internal static extern int Chmod(string path, int mode);
-#pragma warning restore CA2101 // False positive, we can't use unicode charset on Unix, and it uses UTF-8 by default anyway
-#else
- [LibraryImport("libc", EntryPoint = "chmod", SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
- internal static partial int Chmod(string path, int mode);
-#endif
-
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("Windows")]
[return: MarshalAs(UnmanagedType.Bool)]
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
[DllImport("kernel32.dll")]
- internal static extern bool GetConsoleMode(nint hConsoleHandle, out uint lpMode);
+ internal static extern bool GetConsoleMode(nint hConsoleHandle, out EConsoleMode lpMode);
#else
[LibraryImport("kernel32.dll")]
- internal static partial bool GetConsoleMode(nint hConsoleHandle, out uint lpMode);
+ internal static partial bool GetConsoleMode(nint hConsoleHandle, out EConsoleMode lpMode);
#endif
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("FreeBSD")]
[SupportedOSPlatform("Linux")]
[SupportedOSPlatform("MacOS")]
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
[DllImport("libc", EntryPoint = "geteuid", SetLastError = true)]
internal static extern uint GetEuid();
#else
@@ -77,28 +51,28 @@ internal static partial class NativeMethods {
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("Windows")]
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
[DllImport("kernel32.dll")]
- internal static extern nint GetStdHandle(int nStdHandle);
+ internal static extern nint GetStdHandle(EStandardHandle nStdHandle);
#else
[LibraryImport("kernel32.dll")]
- internal static partial nint GetStdHandle(int nStdHandle);
+ internal static partial nint GetStdHandle(EStandardHandle nStdHandle);
#endif
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("Windows")]
[return: MarshalAs(UnmanagedType.Bool)]
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
[DllImport("kernel32.dll")]
- internal static extern bool SetConsoleMode(nint hConsoleHandle, uint dwMode);
+ internal static extern bool SetConsoleMode(nint hConsoleHandle, EConsoleMode dwMode);
#else
[LibraryImport("kernel32.dll")]
- internal static partial bool SetConsoleMode(nint hConsoleHandle, uint dwMode);
+ internal static partial bool SetConsoleMode(nint hConsoleHandle, EConsoleMode dwMode);
#endif
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("Windows")]
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
[DllImport("kernel32.dll")]
internal static extern EExecutionState SetThreadExecutionState(EExecutionState executionState);
#else
@@ -109,20 +83,37 @@ internal static partial class NativeMethods {
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("Windows")]
[return: MarshalAs(UnmanagedType.Bool)]
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
[DllImport("user32.dll")]
- internal static extern void ShowWindow(nint hWnd, int nCmdShow);
+ internal static extern void ShowWindow(nint hWnd, EShowWindow nCmdShow);
#else
[LibraryImport("user32.dll")]
- internal static partial void ShowWindow(nint hWnd, int nCmdShow);
+ internal static partial void ShowWindow(nint hWnd, EShowWindow nCmdShow);
#endif
+ [Flags]
+ [SupportedOSPlatform("Windows")]
+ internal enum EConsoleMode : uint {
+ EnableQuickEditMode = 0x0040
+ }
+
[Flags]
[SupportedOSPlatform("Windows")]
internal enum EExecutionState : uint {
None = 0,
SystemRequired = 0x00000001,
AwayModeRequired = 0x00000040,
- Continuous = 0x80000000
+ Continuous = 0x80000000,
+ Awake = SystemRequired | AwayModeRequired | Continuous
+ }
+
+ [SupportedOSPlatform("Windows")]
+ internal enum EShowWindow : uint {
+ Minimize = 6
+ }
+
+ [SupportedOSPlatform("Windows")]
+ internal enum EStandardHandle {
+ Input = -10
}
}
diff --git a/ArchiSteamFarm/Core/OS.cs b/ArchiSteamFarm/Core/OS.cs
index 47c371b9a..3f0a85145 100644
--- a/ArchiSteamFarm/Core/OS.cs
+++ b/ArchiSteamFarm/Core/OS.cs
@@ -43,7 +43,7 @@ internal static class OS {
internal static readonly string ProcessFileName = Environment.ProcessPath ?? throw new InvalidOperationException(nameof(ProcessFileName));
internal static DateTime ProcessStartTime {
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
get => RuntimeMadness.ProcessStartTime.ToUniversalTime();
#else
get {
@@ -67,7 +67,7 @@ internal static class OS {
framework = "Unknown Framework";
}
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
string runtime = RuntimeInformation.OSArchitecture.ToString();
#else
string runtime = RuntimeInformation.RuntimeIdentifier.Trim();
@@ -195,30 +195,6 @@ internal static class OS {
return true;
}
- [SupportedOSPlatform("FreeBSD")]
- [SupportedOSPlatform("Linux")]
- [SupportedOSPlatform("MacOS")]
- internal static void UnixSetFileAccess(string path, EUnixPermission permission) {
- if (string.IsNullOrEmpty(path)) {
- throw new ArgumentNullException(nameof(path));
- }
-
- if (!OperatingSystem.IsFreeBSD() && !OperatingSystem.IsLinux() && !OperatingSystem.IsMacOS()) {
- throw new PlatformNotSupportedException();
- }
-
- if (!File.Exists(path) && !Directory.Exists(path)) {
- ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"!{nameof(path)}"));
-
- return;
- }
-
- // Chmod() returns 0 on success, -1 on failure
- if (NativeMethods.Chmod(path, (int) permission) != 0) {
- ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, Marshal.GetLastWin32Error()));
- }
- }
-
internal static void UnregisterProcess() {
if (SingleInstance == null) {
return;
@@ -237,7 +213,7 @@ internal static class OS {
}
if (SharedInfo.BuildInfo.Variant.EndsWith("-netf", StringComparison.Ordinal)) {
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
// All Windows variants (7+) have valid .NET Core build
if (OperatingSystem.IsWindows()) {
return false;
@@ -300,15 +276,15 @@ internal static class OS {
throw new PlatformNotSupportedException();
}
- nint consoleHandle = NativeMethods.GetStdHandle(NativeMethods.StandardInputHandle);
+ nint consoleHandle = NativeMethods.GetStdHandle(NativeMethods.EStandardHandle.Input);
- if (!NativeMethods.GetConsoleMode(consoleHandle, out uint consoleMode)) {
+ if (!NativeMethods.GetConsoleMode(consoleHandle, out NativeMethods.EConsoleMode consoleMode)) {
ASF.ArchiLogger.LogGenericError(Strings.WarningFailed);
return;
}
- consoleMode &= ~NativeMethods.EnableQuickEditMode;
+ consoleMode &= ~NativeMethods.EConsoleMode.EnableQuickEditMode;
if (!NativeMethods.SetConsoleMode(consoleHandle, consoleMode)) {
ASF.ArchiLogger.LogGenericError(Strings.WarningFailed);
@@ -324,7 +300,7 @@ internal static class OS {
// This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running
// If user wishes to enter sleep mode, then he should use ShutdownOnFarmingFinished or manage ASF process with third-party tool or script
// See https://docs.microsoft.com/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate for more details
- NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.AwakeExecutionState);
+ NativeMethods.EExecutionState result = NativeMethods.SetThreadExecutionState(NativeMethods.EExecutionState.Awake);
// SetThreadExecutionState() returns NULL on failure, which is mapped to 0 (EExecutionState.None) in our case
if (result == NativeMethods.EExecutionState.None) {
@@ -340,23 +316,6 @@ internal static class OS {
using Process process = Process.GetCurrentProcess();
- NativeMethods.ShowWindow(process.MainWindowHandle, NativeMethods.ShowWindowMinimize);
- }
-
- [Flags]
- [SupportedOSPlatform("FreeBSD")]
- [SupportedOSPlatform("Linux")]
- [SupportedOSPlatform("MacOS")]
- internal enum EUnixPermission : ushort {
- OtherExecute = 0x1,
- OtherWrite = 0x2,
- OtherRead = 0x4,
- GroupExecute = 0x8,
- GroupWrite = 0x10,
- GroupRead = 0x20,
- UserExecute = 0x40,
- UserWrite = 0x80,
- UserRead = 0x100,
- Combined777 = UserRead | UserWrite | UserExecute | GroupRead | GroupWrite | GroupExecute | OtherRead | OtherWrite | OtherExecute
+ NativeMethods.ShowWindow(process.MainWindowHandle, NativeMethods.EShowWindow.Minimize);
}
}
diff --git a/ArchiSteamFarm/Core/Utilities.cs b/ArchiSteamFarm/Core/Utilities.cs
index 495090417..a4de903c6 100644
--- a/ArchiSteamFarm/Core/Utilities.cs
+++ b/ArchiSteamFarm/Core/Utilities.cs
@@ -85,7 +85,7 @@ public static class Utilities {
CookieCollection cookies = cookieContainer.GetCookies(uri);
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
return cookies.Count > 0 ? (from Cookie cookie in cookies where cookie.Name == name select cookie.Value).FirstOrDefault() : null;
#else
return cookies.Count > 0 ? cookies.FirstOrDefault(cookie => cookie.Name == name)?.Value : null;
diff --git a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs
index 17d2f2e2e..04bb4c317 100644
--- a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs
+++ b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs
@@ -179,12 +179,12 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP
return;
}
- if (!Directory.Exists(directoryPath)) {
- Directory.CreateDirectory(directoryPath);
+ // ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
+ if (!Directory.Exists(directoryPath!)) {
+ // ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
+ DirectoryInfo directoryInfo = Directory.CreateDirectory(directoryPath!);
if (OperatingSystem.IsWindows()) {
- DirectoryInfo directoryInfo = new(directoryPath);
-
try {
DirectorySecurity directorySecurity = new(directoryPath, AccessControlSections.All);
@@ -194,17 +194,16 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP
ASF.ArchiLogger.LogGenericDebuggingException(e);
}
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
- // ReSharper disable once RedundantSuppressNullableWarningExpression - required for .NET Framework
- OS.UnixSetFileAccess(directoryPath!, OS.EUnixPermission.Combined777);
+ directoryInfo.UnixFileMode |= UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute | UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute | UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.OtherExecute;
}
}
try {
new FileStream(FilePath, FileMode.CreateNew).Dispose();
- if (OperatingSystem.IsWindows()) {
- FileInfo fileInfo = new(FilePath);
+ FileInfo fileInfo = new(FilePath);
+ if (OperatingSystem.IsWindows()) {
try {
FileSecurity fileSecurity = new(FilePath, AccessControlSections.All);
@@ -214,7 +213,7 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP
ASF.ArchiLogger.LogGenericDebuggingException(e);
}
} else if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
- OS.UnixSetFileAccess(FilePath, OS.EUnixPermission.Combined777);
+ fileInfo.UnixFileMode |= UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute | UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute | UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.OtherExecute;
}
} catch (IOException) {
// Ignored, if the file was already created in the meantime by another instance, this is fine
diff --git a/ArchiSteamFarm/IPC/ArchiKestrel.cs b/ArchiSteamFarm/IPC/ArchiKestrel.cs
index 29e8e124d..0bf203085 100644
--- a/ArchiSteamFarm/IPC/ArchiKestrel.cs
+++ b/ArchiSteamFarm/IPC/ArchiKestrel.cs
@@ -19,7 +19,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
using IHost = Microsoft.AspNetCore.Hosting.IWebHost;
using HostBuilder = Microsoft.AspNetCore.Hosting.WebHostBuilder;
#endif
diff --git a/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs b/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs
index dad28d955..e5f2b82e3 100644
--- a/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs
+++ b/ArchiSteamFarm/IPC/Integration/ApiAuthenticationMiddleware.cs
@@ -19,7 +19,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
using MvcNewtonsoftJsonOptions = Microsoft.AspNetCore.Mvc.MvcJsonOptions;
#endif
using System;
diff --git a/ArchiSteamFarm/IPC/Startup.cs b/ArchiSteamFarm/IPC/Startup.cs
index 51399d3c8..b36d603fa 100644
--- a/ArchiSteamFarm/IPC/Startup.cs
+++ b/ArchiSteamFarm/IPC/Startup.cs
@@ -19,7 +19,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Converters;
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
@@ -134,7 +134,7 @@ internal sealed class Startup {
);
// Use routing for our API controllers, this should be called once we're done with all the static files mess
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
app.UseRouting();
#endif
@@ -153,7 +153,7 @@ internal sealed class Startup {
app.UseWebSockets();
// Finally register proper API endpoints once we're done with routing
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
app.UseMvcWithDefaultRoute();
#else
app.UseEndpoints(static endpoints => endpoints.MapControllers());
@@ -313,7 +313,7 @@ internal sealed class Startup {
mvc.AddControllersAsServices();
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
// Use latest compatibility version for MVC
mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
@@ -333,7 +333,7 @@ internal sealed class Startup {
options.SerializerSettings.Formatting = Formatting.Indented;
}
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
// .NET Framework serializes Version as object by default, serialize it as string just like .NET Core
options.SerializerSettings.Converters.Add(new VersionConverter());
#endif
diff --git a/ArchiSteamFarm/IPC/WebUtilities.cs b/ArchiSteamFarm/IPC/WebUtilities.cs
index 7793d84d5..1c9e57d05 100644
--- a/ArchiSteamFarm/IPC/WebUtilities.cs
+++ b/ArchiSteamFarm/IPC/WebUtilities.cs
@@ -19,7 +19,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
#endif
@@ -35,7 +35,7 @@ using Newtonsoft.Json;
namespace ArchiSteamFarm.IPC;
internal static class WebUtilities {
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
internal static IMvcCoreBuilder AddControllers(this IServiceCollection services) {
ArgumentNullException.ThrowIfNull(services);
diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs
index 41db2ccde..29707eeff 100644
--- a/ArchiSteamFarm/Program.cs
+++ b/ArchiSteamFarm/Program.cs
@@ -43,7 +43,7 @@ using Newtonsoft.Json;
using NLog;
using NLog.Targets;
using SteamKit2;
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
using System.Net.Quic;
#endif
@@ -59,13 +59,13 @@ internal static class Program {
internal static bool ShutdownSequenceInitialized { get; private set; }
internal static bool SteamParentalGeneration { get; private set; } = true;
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
private static readonly Dictionary RegisteredPosixSignals = new();
#endif
private static readonly TaskCompletionSource ShutdownResetEvent = new();
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
private static readonly ImmutableHashSet SupportedPosixSignals = ImmutableHashSet.Create(PosixSignal.SIGINT, PosixSignal.SIGTERM);
#endif
@@ -193,7 +193,7 @@ internal static class Program {
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
RuntimeMadness.Initialize();
#else
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
@@ -465,7 +465,7 @@ internal static class Program {
ShutdownSequenceInitialized = true;
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
if (OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) {
// Unregister from registered signals
foreach (PosixSignalRegistration registration in RegisteredPosixSignals.Values) {
@@ -510,7 +510,7 @@ internal static class Program {
private static async void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e) => await Exit(130).ConfigureAwait(false);
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
private static async void OnPosixSignal(PosixSignalContext signal) {
ArgumentNullException.ThrowIfNull(signal);
diff --git a/ArchiSteamFarm/Web/WebBrowser.cs b/ArchiSteamFarm/Web/WebBrowser.cs
index 06312a15c..3c38db9ee 100644
--- a/ArchiSteamFarm/Web/WebBrowser.cs
+++ b/ArchiSteamFarm/Web/WebBrowser.cs
@@ -65,7 +65,7 @@ public sealed class WebBrowser : IDisposable {
HttpClientHandler = new HttpClientHandler {
AllowAutoRedirect = false, // This must be false if we want to handle custom redirection schemes such as "steammobile://"
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
#else
AutomaticDecompression = DecompressionMethods.All,
@@ -85,7 +85,7 @@ public sealed class WebBrowser : IDisposable {
}
}
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
if (!RuntimeMadness.IsRunningOnMono) {
HttpClientHandler.MaxConnectionsPerServer = MaxConnections;
}
@@ -106,7 +106,7 @@ public sealed class WebBrowser : IDisposable {
byte connectionTimeout = ASF.GlobalConfig?.ConnectionTimeout ?? GlobalConfig.DefaultConnectionTimeout;
HttpClient result = new(HttpClientHandler, false) {
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
DefaultRequestVersion = HttpVersion.Version30,
#endif
Timeout = TimeSpan.FromSeconds(extendedTimeout ? ExtendedTimeout : connectionTimeout)
@@ -662,7 +662,7 @@ public sealed class WebBrowser : IDisposable {
using StreamReader streamReader = new(response.Content);
#pragma warning disable CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
- JsonReader jsonReader = new JsonTextReader(streamReader);
+ JsonTextReader jsonReader = new(streamReader);
#pragma warning restore CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
await using (jsonReader.ConfigureAwait(false)) {
@@ -766,7 +766,7 @@ public sealed class WebBrowser : IDisposable {
ServicePointManager.Expect100Continue = false;
// Reuse ports if possible
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
if (!RuntimeMadness.IsRunningOnMono) {
ServicePointManager.ReusePort = true;
}
@@ -801,7 +801,7 @@ public sealed class WebBrowser : IDisposable {
while (true) {
using (HttpRequestMessage requestMessage = new(httpMethod, request)) {
-#if !NETFRAMEWORK
+#if !NETFRAMEWORK && !NETSTANDARD
requestMessage.Version = HttpClient.DefaultRequestVersion;
#endif
diff --git a/ArchiSteamFarm/Web/WebBrowserUtilities.cs b/ArchiSteamFarm/Web/WebBrowserUtilities.cs
index 9b061ff9a..78a80567b 100644
--- a/ArchiSteamFarm/Web/WebBrowserUtilities.cs
+++ b/ArchiSteamFarm/Web/WebBrowserUtilities.cs
@@ -59,7 +59,7 @@ internal static class WebBrowserUtilities {
private static (Stream CompressionInput, string ContentEncoding) GetBestSupportedCompressionMethod(Stream output) {
ArgumentNullException.ThrowIfNull(output);
-#if NETFRAMEWORK
+#if NETFRAMEWORK || NETSTANDARD
return (new GZipStream(output, CompressionLevel.Optimal, true), "gzip");
#else
return (new BrotliStream(output, CompressionLevel.SmallestSize, true), "br");
diff --git a/Directory.Build.props b/Directory.Build.props
index f5f3eb136..7cd4b0d53 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -29,18 +29,19 @@
$(PackageProjectUrl).git
LatestMajor
linux-arm;linux-arm64;linux-x64;osx-arm64;osx-x64;win-x64
+ net7.0
true
- net7.0;net481
+ $(TargetFrameworks);net481
-
- net7.0
+
+ $(TargetFrameworks);netstandard2.1
-
+
@@ -48,9 +49,13 @@
+
+
+
+
@@ -63,6 +68,11 @@
+
+
+
+
+
$(DefineConstants);ASF_VARIANT_$(ASFVariant.Replace('-', '_').ToUpperInvariant())
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 86341c14e..9fa29ab87 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -26,8 +26,8 @@
-
-
+
+
@@ -40,4 +40,8 @@
+
+
+
+