From af01b0ed4825547706c80e1b1dc7e41078635d83 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 21 Nov 2021 06:30:14 +0300 Subject: [PATCH] `BASE_DERIVED` -> `BASE_TYPE_MAPPING` --- .../Online/SignalRDerivedTypeWorkaroundJsonConverter.cs | 4 ++-- osu.Game/Online/SignalRUnionWorkaroundResolver.cs | 6 +++--- osu.Game/Online/SignalRWorkaroundTypes.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Online/SignalRDerivedTypeWorkaroundJsonConverter.cs b/osu.Game/Online/SignalRDerivedTypeWorkaroundJsonConverter.cs index 5643c5ca74..ab04e046d3 100644 --- a/osu.Game/Online/SignalRDerivedTypeWorkaroundJsonConverter.cs +++ b/osu.Game/Online/SignalRDerivedTypeWorkaroundJsonConverter.cs @@ -17,7 +17,7 @@ namespace osu.Game.Online public class SignalRDerivedTypeWorkaroundJsonConverter : JsonConverter { public override bool CanConvert(Type objectType) => - SignalRWorkaroundTypes.BASE_DERIVED.Any(t => + SignalRWorkaroundTypes.BASE_TYPE_MAPPING.Any(t => objectType == t.baseType || objectType == t.derivedType); @@ -30,7 +30,7 @@ namespace osu.Game.Online string type = (string)obj[@"$dtype"]!; - var resolvedType = SignalRWorkaroundTypes.BASE_DERIVED.Select(t => t.derivedType).Single(t => t.Name == type); + var resolvedType = SignalRWorkaroundTypes.BASE_TYPE_MAPPING.Select(t => t.derivedType).Single(t => t.Name == type); object? instance = Activator.CreateInstance(resolvedType); diff --git a/osu.Game/Online/SignalRUnionWorkaroundResolver.cs b/osu.Game/Online/SignalRUnionWorkaroundResolver.cs index 01e3c24c87..e64f9ed91c 100644 --- a/osu.Game/Online/SignalRUnionWorkaroundResolver.cs +++ b/osu.Game/Online/SignalRUnionWorkaroundResolver.cs @@ -23,13 +23,13 @@ namespace osu.Game.Online private static IReadOnlyDictionary createFormatterMap() { - IEnumerable<(Type derivedType, Type baseType)> baseDerived = SignalRWorkaroundTypes.BASE_DERIVED; + IEnumerable<(Type derivedType, Type baseType)> baseMap = SignalRWorkaroundTypes.BASE_TYPE_MAPPING; // This should not be required. The fallback should work. But something is weird with the way caching is done. // For future adventurers, I would not advise looking into this further. It's likely not worth the effort. - baseDerived = baseDerived.Concat(baseDerived.Select(t => (t.baseType, t.baseType))).Distinct(); + baseMap = baseMap.Concat(baseMap.Select(t => (t.baseType, t.baseType))); - return new Dictionary(baseDerived.Select(t => + return new Dictionary(baseMap.Select(t => { var formatter = (IMessagePackFormatter)Activator.CreateInstance(typeof(TypeRedirectingFormatter<,>).MakeGenericType(t.derivedType, t.baseType)); return new KeyValuePair(t.derivedType, formatter); diff --git a/osu.Game/Online/SignalRWorkaroundTypes.cs b/osu.Game/Online/SignalRWorkaroundTypes.cs index ae1d9f9c6e..f69d23d81c 100644 --- a/osu.Game/Online/SignalRWorkaroundTypes.cs +++ b/osu.Game/Online/SignalRWorkaroundTypes.cs @@ -15,7 +15,7 @@ namespace osu.Game.Online /// internal static class SignalRWorkaroundTypes { - internal static readonly IReadOnlyList<(Type derivedType, Type baseType)> BASE_DERIVED = new[] + internal static readonly IReadOnlyList<(Type derivedType, Type baseType)> BASE_TYPE_MAPPING = new[] { (typeof(ChangeTeamRequest), typeof(MatchUserRequest)), (typeof(TeamVersusRoomState), typeof(MatchRoomState)),