1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

Avoid serialising some more properties of SoloScoreInfo unless present

This commit is contained in:
Dean Herbert 2022-10-21 19:01:28 +09:00
parent 703a8afb11
commit af84f708b7

View File

@ -114,6 +114,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("has_replay")]
public bool HasReplay { get; set; }
// These properties are calculated or not relevant to any external usage.
public bool ShouldSerializeID() => false;
public bool ShouldSerializeUser() => false;
public bool ShouldSerializeBeatmap() => false;
@ -122,6 +123,18 @@ namespace osu.Game.Online.API.Requests.Responses
public bool ShouldSerializeOnlineID() => false;
public bool ShouldSerializeHasReplay() => false;
// These fields only need to be serialised if they hold values.
// Generally this is required because this model may be used by server-side components, but
// we don't want to bother sending these fields in score submission requests, for instance.
public bool ShouldSerializeEndedAt() => EndedAt != default;
public bool ShouldSerializeStartedAt() => StartedAt != default;
public bool ShouldSerializeLegacyScoreId() => LegacyScoreId != null;
public bool ShouldSerializeLegacyTotalScore() => LegacyTotalScore != null;
public bool ShouldSerializeMods() => Mods.Length > 0;
public bool ShouldSerializeUserID() => UserID > 0;
public bool ShouldSerializeBeatmapID() => BeatmapID > 0;
public bool ShouldSerializeBuildID() => BuildID != null;
#endregion
public override string ToString() => $"score_id: {ID} user_id: {UserID}";