From 1f2dd8d3591b25f42d23b2dd1351851341720167 Mon Sep 17 00:00:00 2001 From: Kornei Dontsov Date: Mon, 16 Jan 2023 19:07:21 +0300 Subject: [PATCH] [Unity3D-sdk] No ConcurrentDictionary duplicates ConcurrentDictionary is released in .NET 4 and it is present in modern Unity API compatibility levels: .NET 4.x and .NET Standard 2.x. It's missed in legacy API compatibility levels: .NET 2.0 and .NET 2.0 Subset. This commit proposes to add custom implementation of ConcurrentDictionary for legacy API compatibility levels, and use the existing ConcurrentDictionary for modern API compatibility levels. I also remove the usage of define UNITY_WSA, because it only produces compile errors when build WSA, and because Poco-SDK doesn't build to WSA at all (due to System.Net.Sockets cannot be used for WSA, so TcpServer cannot be compiled). --- Unity3D/ConcurrentDictionary.cs | 4 ++-- Unity3D/PocoManager.cs | 1 + Unity3D/TcpServer.cs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Unity3D/ConcurrentDictionary.cs b/Unity3D/ConcurrentDictionary.cs index 508ec95..ebb18bf 100644 --- a/Unity3D/ConcurrentDictionary.cs +++ b/Unity3D/ConcurrentDictionary.cs @@ -1,4 +1,4 @@ -#if !UNITY_WSA +#if !UNITY_5_6_OR_NEWER || NET_2_0 || NET_2_0_SUBSET using System; using System.Collections; using System.Collections.Generic; @@ -8,7 +8,7 @@ using System.Runtime.Serialization; using System.Threading; -namespace TcpServer +namespace System.Collections.Concurrent { /// diff --git a/Unity3D/PocoManager.cs b/Unity3D/PocoManager.cs index c2c46f8..467c059 100644 --- a/Unity3D/PocoManager.cs +++ b/Unity3D/PocoManager.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json.Linq; using Poco; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; diff --git a/Unity3D/TcpServer.cs b/Unity3D/TcpServer.cs index ed06c63..36bec37 100644 --- a/Unity3D/TcpServer.cs +++ b/Unity3D/TcpServer.cs @@ -1,6 +1,7 @@ using System; using System.Threading; using System.Collections; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Net;