* Good start

* Misc

* Make ApiAuthenticationMiddleware use new json

* Remove first newtonsoft dependency

* Pull latest ASFB json enhancements

* Start reimplementing newtonsoft!

* One thing at a time

* Keep doing all kind of breaking changes which need to be tested later

* Add back ShouldSerialize() support

* Misc

* Eradicate remaining parts of newtonsoft

* WIP

* Workaround STJ stupidity in regards to derived types

STJ can't serialize derived type properties by default, so we'll use another approach in our serializable file function

* Make CI happy

* Bunch of further fixes

* Fix AddFreeLicense() after rewrite

* Add full support for JsonDisallowNullAttribute

* Optimize our json utilities even further

* Misc

* Add support for fields in disallow null

* Misc optimization

* Fix deserialization of GlobalCache in STD

* Fix non-public [JsonExtensionData]

* Fix IM missing method exception, correct db storage helpers

* Fix saving into generic databases

Thanks STJ

* Make Save() function abstract to force inheritors to implement it properly

* Correct ShouldSerializeAdditionalProperties to be a method

* Misc cleanup

* Code review

* Allow JSON comments in configs, among other

* Allow trailing commas in configs

Users very often add them accidentally, no reason to throw on them

* Fix confirmation ID

Probably needs further fixes, will need to check later

* Correct confirmations deserialization

* Use JsonNumberHandling

* Misc

* Misc

* [JsonDisallowNull] corrections

* Forbid [JsonDisallowNull] on non-nullable structs

* Not really but okay

* Add and use ToJson() helpers

* Misc

* Misc
This commit is contained in:
Łukasz Domeradzki
2024-02-21 03:09:36 +01:00
committed by GitHub
parent 3968130e15
commit 6b0bf0f9c1
114 changed files with 1714 additions and 1212 deletions

View File

@@ -20,10 +20,10 @@
// limitations under the License.
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ArchiSteamFarm.Plugins.Interfaces;
@@ -33,5 +33,5 @@ public interface IASF : IPlugin {
/// ASF will call this method right after global config initialization.
/// </summary>
/// <param name="additionalConfigProperties">Extra config properties made out of <see cref="JsonExtensionDataAttribute" />. Can be null if no extra properties are found.</param>
Task OnASFInit(IReadOnlyDictionary<string, JToken>? additionalConfigProperties = null);
Task OnASFInit(IReadOnlyDictionary<string, JsonElement>? additionalConfigProperties = null);
}

View File

@@ -20,11 +20,11 @@
// limitations under the License.
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using ArchiSteamFarm.Steam;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ArchiSteamFarm.Plugins.Interfaces;
@@ -35,5 +35,5 @@ public interface IBotModules : IPlugin {
/// </summary>
/// <param name="bot">Bot object related to this callback.</param>
/// <param name="additionalConfigProperties">Extra config properties made out of <see cref="JsonExtensionDataAttribute" />. Can be null if no extra properties are found.</param>
Task OnBotInitModules(Bot bot, IReadOnlyDictionary<string, JToken>? additionalConfigProperties = null);
Task OnBotInitModules(Bot bot, IReadOnlyDictionary<string, JsonElement>? additionalConfigProperties = null);
}

View File

@@ -20,9 +20,10 @@
// limitations under the License.
using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Newtonsoft.Json;
namespace ArchiSteamFarm.Plugins.Interfaces;
@@ -32,7 +33,8 @@ public interface IPlugin {
/// ASF will use this property as general plugin identifier for the user.
/// </summary>
/// <returns>String that will be used as the name of this plugin.</returns>
[JsonProperty]
[JsonInclude]
[Required]
string Name { get; }
/// <summary>
@@ -40,7 +42,8 @@ public interface IPlugin {
/// You have a freedom in deciding what versioning you want to use, this is for identification purposes only.
/// </summary>
/// <returns>Version that will be shown to the user when plugin is loaded.</returns>
[JsonProperty]
[JsonInclude]
[Required]
Version Version { get; }
/// <summary>

View File

@@ -19,7 +19,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace ArchiSteamFarm.Plugins.Interfaces;
@@ -35,6 +35,6 @@ public interface IWebInterface : IPlugin {
/// <summary>
/// Specifies web path (address) under which ASF should host your static WWW files in <see cref="PhysicalPath" /> directory. Default value of "/" allows you to override default ASF files and gives you full flexibility in your <see cref="PhysicalPath" /> directory. However, you can instead host your files under some other fixed location specified here, such as "/MyPlugin".
/// </summary>
[JsonProperty]
[JsonInclude]
string WebPath => "/";
}

View File

@@ -33,6 +33,7 @@ using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Helpers;
@@ -43,7 +44,6 @@ using ArchiSteamFarm.Steam.Data;
using ArchiSteamFarm.Steam.Exchange;
using ArchiSteamFarm.Steam.Integration.Callbacks;
using JetBrains.Annotations;
using Newtonsoft.Json.Linq;
using SteamKit2;
namespace ArchiSteamFarm.Plugins;
@@ -286,7 +286,7 @@ public static class PluginsCore {
return assemblies;
}
internal static async Task OnASFInitModules(IReadOnlyDictionary<string, JToken>? additionalConfigProperties = null) {
internal static async Task OnASFInitModules(IReadOnlyDictionary<string, JsonElement>? additionalConfigProperties = null) {
if (ActivePlugins.Count == 0) {
return;
}
@@ -436,7 +436,7 @@ public static class PluginsCore {
}
}
internal static async Task OnBotInitModules(Bot bot, IReadOnlyDictionary<string, JToken>? additionalConfigProperties = null) {
internal static async Task OnBotInitModules(Bot bot, IReadOnlyDictionary<string, JsonElement>? additionalConfigProperties = null) {
ArgumentNullException.ThrowIfNull(bot);
if (ActivePlugins.Count == 0) {