1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Merge pull request #16268 from bdach/implicit-newtonsoft-properties

Revert rename of implicitly-used newtonsoft method
This commit is contained in:
Dean Herbert 2021-12-28 18:45:08 +09:00 committed by GitHub
commit f2ed8af9cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 2 deletions

View File

@ -70,8 +70,15 @@ namespace osu.Game.Rulesets.Osu.Difficulty
SliderFactor = values[ATTRIB_ID_SLIDER_FACTOR]; 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] [UsedImplicitly]
public bool ShouldSerializeFlashlightRating() => Mods.Any(m => m is ModFlashlight); public bool ShouldSerializeFlashlightRating() => Mods.Any(m => m is ModFlashlight);
#endregion
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -112,8 +113,20 @@ 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; public bool ShouldSerializeID() => false;
public bool ShouldSerializeAPIBeatmap() => false;
// ReSharper disable once IdentifierTypo
[UsedImplicitly]
public bool ShouldSerializeapiBeatmap() => false;
#endregion
public bool Equals(PlaylistItem other) public bool Equals(PlaylistItem other)
=> ID == other?.ID => ID == other?.ID

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -211,8 +212,21 @@ namespace osu.Game.Online.Rooms
Playlist.RemoveAll(i => i.Expired); 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; public bool ShouldSerializeRoomID() => false;
[UsedImplicitly]
public bool ShouldSerializeHost() => false; public bool ShouldSerializeHost() => false;
[UsedImplicitly]
public bool ShouldSerializeEndDate() => false; public bool ShouldSerializeEndDate() => false;
#endregion
} }
} }