Cleanup round

This commit is contained in:
JustArchi
2021-05-06 21:00:21 +02:00
parent aed11c59ee
commit a8e3bd6473
3 changed files with 8 additions and 16 deletions

View File

@@ -19,12 +19,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#if NETFRAMEWORK
using ArchiSteamFarm.RuntimeCompatibility;
using File = System.IO.File;
#else
using System.IO;
#endif
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -35,6 +29,7 @@ using System.Threading;
using System.Threading.Tasks;
using ArchiSteamFarm.Json;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.RuntimeCompatibility;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -341,12 +336,12 @@ namespace ArchiSteamFarm {
await WriteSemaphore.WaitAsync().ConfigureAwait(false);
try {
await RuntimeCompatibility.File.WriteAllTextAsync(newFilePath, json).ConfigureAwait(false);
await File.WriteAllTextAsync(newFilePath, json).ConfigureAwait(false);
if (File.Exists(filePath)) {
File.Replace(newFilePath, filePath, null);
if (System.IO.File.Exists(filePath)) {
System.IO.File.Replace(newFilePath, filePath, null);
} else {
File.Move(newFilePath, filePath);
System.IO.File.Move(newFilePath, filePath);
}
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);
@@ -430,14 +425,14 @@ namespace ArchiSteamFarm {
throw new ArgumentNullException(nameof(filePath));
}
if (!File.Exists(filePath)) {
if (!System.IO.File.Exists(filePath)) {
return null;
}
BotConfig? botConfig;
try {
string json = await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false);
string json = await File.ReadAllTextAsync(filePath).ConfigureAwait(false);
if (string.IsNullOrEmpty(json)) {
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsEmpty, nameof(json)));

View File

@@ -265,7 +265,6 @@ namespace ArchiSteamFarm.IPC {
mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
#if NETFRAMEWORK
// Add standard formatters
mvc.AddFormatterMappings();
@@ -274,7 +273,6 @@ namespace ArchiSteamFarm.IPC {
#endif
#if NETFRAMEWORK
// Add JSON formatters that will be used as default ones if no specific formatters are asked for
mvc.AddJsonFormatters();
@@ -291,7 +289,6 @@ namespace ArchiSteamFarm.IPC {
}
#if NETFRAMEWORK
// .NET Framework serializes Version as object by default, serialize it as string just like .NET Core
options.SerializerSettings.Converters.Add(new VersionConverter());
#endif

View File

@@ -169,7 +169,6 @@ namespace ArchiSteamFarm {
internal static bool VerifyEnvironment() {
#if NETFRAMEWORK
// 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
@@ -193,6 +192,7 @@ namespace ArchiSteamFarm {
_ => false
};
#else
// This is .NET Core build, we support all scenarios
return true;
#endif