From bc39c2a877500e744051c41c3f93432815453250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 28 Dec 2021 08:31:27 +0100 Subject: [PATCH 1/2] Revert incorrect property rename --- osu.Game/Online/Rooms/PlaylistItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Rooms/PlaylistItem.cs b/osu.Game/Online/Rooms/PlaylistItem.cs index 231e214ab9..b8700fd067 100644 --- a/osu.Game/Online/Rooms/PlaylistItem.cs +++ b/osu.Game/Online/Rooms/PlaylistItem.cs @@ -113,7 +113,7 @@ namespace osu.Game.Online.Rooms } public bool ShouldSerializeID() => false; - public bool ShouldSerializeAPIBeatmap() => false; + public bool ShouldSerializeapiBeatmap() => false; public bool Equals(PlaylistItem other) => ID == other?.ID From 63e0492725db617ec50dfbf5baa6428715bb3621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 28 Dec 2021 08:37:16 +0100 Subject: [PATCH 2/2] Mark `ShouldSerialize()` methods as implicitly used --- .../Difficulty/OsuDifficultyAttributes.cs | 9 ++++++++- osu.Game/Online/Rooms/PlaylistItem.cs | 13 +++++++++++++ osu.Game/Online/Rooms/Room.cs | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs index 128ff772fd..126a9b0183 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyAttributes.cs @@ -70,8 +70,15 @@ namespace osu.Game.Rulesets.Osu.Difficulty SliderFactor = values[ATTRIB_ID_SLIDER_FACTOR]; } - // Used implicitly by Newtonsoft.Json to not serialize flashlight property in some cases. + #region Newtonsoft.Json implicit ShouldSerialize() methods + + // The properties in this region are used implicitly by Newtonsoft.Json to not serialise certain fields in some cases. + // They rely on being named exactly the same as the corresponding fields (casing included) and as such should NOT be renamed + // unless the fields are also renamed. + [UsedImplicitly] public bool ShouldSerializeFlashlightRating() => Mods.Any(m => m is ModFlashlight); + + #endregion } } diff --git a/osu.Game/Online/Rooms/PlaylistItem.cs b/osu.Game/Online/Rooms/PlaylistItem.cs index b8700fd067..83a70c405b 100644 --- a/osu.Game/Online/Rooms/PlaylistItem.cs +++ b/osu.Game/Online/Rooms/PlaylistItem.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Linq; +using JetBrains.Annotations; using Newtonsoft.Json; using osu.Framework.Bindables; using osu.Game.Beatmaps; @@ -112,9 +113,21 @@ namespace osu.Game.Online.Rooms } } + #region Newtonsoft.Json implicit ShouldSerialize() methods + + // The properties in this region are used implicitly by Newtonsoft.Json to not serialise certain fields in some cases. + // They rely on being named exactly the same as the corresponding fields (casing included) and as such should NOT be renamed + // unless the fields are also renamed. + + [UsedImplicitly] public bool ShouldSerializeID() => false; + + // ReSharper disable once IdentifierTypo + [UsedImplicitly] public bool ShouldSerializeapiBeatmap() => false; + #endregion + public bool Equals(PlaylistItem other) => ID == other?.ID && BeatmapID == other.BeatmapID diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index c87411c3c0..bbe854f2dd 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using JetBrains.Annotations; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -211,8 +212,21 @@ namespace osu.Game.Online.Rooms Playlist.RemoveAll(i => i.Expired); } + #region Newtonsoft.Json implicit ShouldSerialize() methods + + // The properties in this region are used implicitly by Newtonsoft.Json to not serialise certain fields in some cases. + // They rely on being named exactly the same as the corresponding fields (casing included) and as such should NOT be renamed + // unless the fields are also renamed. + + [UsedImplicitly] public bool ShouldSerializeRoomID() => false; + + [UsedImplicitly] public bool ShouldSerializeHost() => false; + + [UsedImplicitly] public bool ShouldSerializeEndDate() => false; + + #endregion } }