Address todos relating to init-only usages

This commit is contained in:
Joseph Madamba
2023-02-08 17:51:28 -08:00
parent 2873905cc6
commit f1decb667e
4 changed files with 16 additions and 21 deletions

View File

@ -66,10 +66,12 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
int days = ranked_days - index + 1; int days = ranked_days - index + 1;
return new UserGraphTooltipContent( return new UserGraphTooltipContent
UsersStrings.ShowRankGlobalSimple, {
rank.ToLocalisableString("\\##,##0"), Name = UsersStrings.ShowRankGlobalSimple,
days == 0 ? "now" : $"{"day".ToQuantity(days)} ago"); Count = rank.ToLocalisableString("\\##,##0"),
Time = days == 0 ? "now" : $"{"day".ToQuantity(days)} ago",
};
} }
} }
} }

View File

@ -27,9 +27,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
protected override float GetDataPointHeight(long playCount) => playCount; protected override float GetDataPointHeight(long playCount) => playCount;
protected override UserGraphTooltipContent GetTooltipContent(DateTime date, long playCount) => protected override UserGraphTooltipContent GetTooltipContent(DateTime date, long playCount) =>
new UserGraphTooltipContent( new UserGraphTooltipContent
tooltipCounterName, {
playCount.ToLocalisableString("N0"), Name = tooltipCounterName,
date.ToLocalisableString("MMMM yyyy")); Count = playCount.ToLocalisableString("N0"),
Time = date.ToLocalisableString("MMMM yyyy")
};
} }
} }

View File

@ -298,16 +298,8 @@ namespace osu.Game.Overlays.Profile
public class UserGraphTooltipContent public class UserGraphTooltipContent
{ {
// todo: could use init-only properties on C# 9 which read better than a constructor. public LocalisableString Name { get; init; }
public LocalisableString Name { get; } public LocalisableString Count { get; init; }
public LocalisableString Count { get; } public LocalisableString Time { get; init; }
public LocalisableString Time { get; }
public UserGraphTooltipContent(LocalisableString name, LocalisableString count, LocalisableString time)
{
Name = name;
Count = count;
Time = time;
}
} }
} }

View File

@ -20,8 +20,7 @@ namespace osu.Game.Tests.Visual
/// <summary> /// <summary>
/// The dependencies provided to the children. /// The dependencies provided to the children.
/// </summary> /// </summary>
// TODO: should be an init-only property when C# 9 public (Type, object)[] CachedDependencies { get; init; } = Array.Empty<(Type, object)>();
public (Type, object)[] CachedDependencies { get; set; } = Array.Empty<(Type, object)>();
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {