From 0342923408b83b2300ff70dbf8baa3308df63a07 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 19 Nov 2021 19:03:52 +0300 Subject: [PATCH] Fix SignalR messagepack formatter potentially initializing on iOS --- osu.Game/Online/SignalRUnionWorkaroundResolver.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/SignalRUnionWorkaroundResolver.cs b/osu.Game/Online/SignalRUnionWorkaroundResolver.cs index 21413f8285..89052ad052 100644 --- a/osu.Game/Online/SignalRUnionWorkaroundResolver.cs +++ b/osu.Game/Online/SignalRUnionWorkaroundResolver.cs @@ -35,7 +35,9 @@ public class SignalRUnionWorkaroundResolver : IFormatterResolver typeof(TeamVersusUserState), }; - private static readonly IReadOnlyDictionary formatter_map = new Dictionary + private static IReadOnlyDictionary formatterMapBacking; + + private static IReadOnlyDictionary formatterMap => formatterMapBacking ??= new Dictionary { { typeof(TeamVersusUserState), new TypeRedirectingFormatter() }, { typeof(TeamVersusRoomState), new TypeRedirectingFormatter() }, @@ -51,7 +53,7 @@ public class SignalRUnionWorkaroundResolver : IFormatterResolver public IMessagePackFormatter GetFormatter() { - if (formatter_map.TryGetValue(typeof(T), out var formatter)) + if (formatterMap.TryGetValue(typeof(T), out var formatter)) return (IMessagePackFormatter)formatter; return StandardResolver.Instance.GetFormatter();