1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 19:43:22 +08:00

Remove IJsonSerializable interface

Was pretty pointless and made it hard to use the custom serialisation
terms arbitrarily in tests.
This commit is contained in:
Dean Herbert 2021-08-31 14:38:35 +09:00
parent d6a0d2aa44
commit c25ab6835c
7 changed files with 7 additions and 20 deletions

View File

@ -10,7 +10,6 @@ using Newtonsoft.Json;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -18,7 +17,7 @@ namespace osu.Game.Beatmaps
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
[Serializable] [Serializable]
public class BeatmapInfo : IEquatable<BeatmapInfo>, IJsonSerializable, IHasPrimaryKey public class BeatmapInfo : IEquatable<BeatmapInfo>, IHasPrimaryKey
{ {
public int ID { get; set; } public int ID { get; set; }

View File

@ -4,12 +4,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
public interface IBeatmap : IJsonSerializable public interface IBeatmap
{ {
/// <summary> /// <summary>
/// This beatmap's info. /// This beatmap's info.

View File

@ -7,21 +7,14 @@ using osu.Framework.IO.Serialization;
namespace osu.Game.IO.Serialization namespace osu.Game.IO.Serialization
{ {
public interface IJsonSerializable
{
}
public static class JsonSerializableExtensions public static class JsonSerializableExtensions
{ {
public static string Serialize(this IJsonSerializable obj) => JsonConvert.SerializeObject(obj, CreateGlobalSettings()); public static string Serialize(this object obj) => JsonConvert.SerializeObject(obj, CreateGlobalSettings());
public static T Deserialize<T>(this string objString) => JsonConvert.DeserializeObject<T>(objString, CreateGlobalSettings()); public static T Deserialize<T>(this string objString) => JsonConvert.DeserializeObject<T>(objString, CreateGlobalSettings());
public static void DeserializeInto<T>(this string objString, T target) => JsonConvert.PopulateObject(objString, target, CreateGlobalSettings()); public static void DeserializeInto<T>(this string objString, T target) => JsonConvert.PopulateObject(objString, target, CreateGlobalSettings());
/// <summary>
/// Creates the default <see cref="JsonSerializerSettings"/> that should be used for all <see cref="IJsonSerializable"/>s.
/// </summary>
public static JsonSerializerSettings CreateGlobalSettings() => new JsonSerializerSettings public static JsonSerializerSettings CreateGlobalSettings() => new JsonSerializerSettings
{ {
ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore,

View File

@ -11,7 +11,6 @@ using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Utils; using osu.Game.Utils;
@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
/// The base class for gameplay modifiers. /// The base class for gameplay modifiers.
/// </summary> /// </summary>
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable, IDeepCloneable<Mod> public abstract class Mod : IMod, IEquatable<Mod>, IDeepCloneable<Mod>
{ {
/// <summary> /// <summary>
/// The name of this mod. /// The name of this mod.

View File

@ -3,14 +3,13 @@
using System; using System;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.IO.Serialization;
namespace osu.Game.Rulesets.Timing namespace osu.Game.Rulesets.Timing
{ {
/// <summary> /// <summary>
/// A control point which adds an aggregated multiplier based on the provided <see cref="TimingPoint"/>'s BeatLength and <see cref="DifficultyPoint"/>'s SpeedMultiplier. /// A control point which adds an aggregated multiplier based on the provided <see cref="TimingPoint"/>'s BeatLength and <see cref="DifficultyPoint"/>'s SpeedMultiplier.
/// </summary> /// </summary>
public class MultiplierControlPoint : IJsonSerializable, IComparable<MultiplierControlPoint> public class MultiplierControlPoint : IComparable<MultiplierControlPoint>
{ {
/// <summary> /// <summary>
/// The time in milliseconds at which this <see cref="MultiplierControlPoint"/> starts. /// The time in milliseconds at which this <see cref="MultiplierControlPoint"/> starts.

View File

@ -4,13 +4,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.IO.Serialization;
using osu.Game.IO.Serialization.Converters; using osu.Game.IO.Serialization.Converters;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
{ {
public class ClipboardContent : IJsonSerializable public class ClipboardContent
{ {
[JsonConverter(typeof(TypedListConverter<HitObject>))] [JsonConverter(typeof(TypedListConverter<HitObject>))]
public IList<HitObject> HitObjects; public IList<HitObject> HitObjects;

View File

@ -8,7 +8,6 @@ using Newtonsoft.Json;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.IO.Serialization;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -18,7 +17,7 @@ namespace osu.Game.Screens.Play.HUD
/// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>. /// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class SkinnableInfo : IJsonSerializable public class SkinnableInfo
{ {
public Type Type { get; set; } public Type Type { get; set; }