From 08e7c14ced3a2d609a60095a09d754498d38e1d5 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 8 Jun 2020 08:33:27 -0300 Subject: [PATCH] drop unused code related to PORTABLE flag (#2202) --- Octokit/Helpers/ConcurrentCache.cs | 39 --------------------- Octokit/Http/HttpClientAdapter.cs | 4 +-- Octokit/Http/HttpMessageHandlerFactory.cs | 5 +-- Octokit/Models/Request/RequestParameters.cs | 10 ++---- 4 files changed, 7 insertions(+), 51 deletions(-) delete mode 100644 Octokit/Helpers/ConcurrentCache.cs diff --git a/Octokit/Helpers/ConcurrentCache.cs b/Octokit/Helpers/ConcurrentCache.cs deleted file mode 100644 index 55e6d3d2..00000000 --- a/Octokit/Helpers/ConcurrentCache.cs +++ /dev/null @@ -1,39 +0,0 @@ -#if PORTABLE -using System; -using System.Collections.Generic; -using System.Threading; - -namespace Octokit -{ - /// - /// This is in lieu of ConcurrentDictionary. PCL runtime, specifically windows phone 8 - /// does not have access to ConcurrentDictionary. We just use a lock. - /// - /// - /// - [Obsolete("This component is no longer used, and will be removed in a future update")] - public class ConcurrentCache - { - Dictionary _cache = new Dictionary(); - - public TValue GetOrAdd(TKey key, Func valueFactory) - { - //cannot be null - if (valueFactory == null) - throw new ArgumentNullException("valueFactory"); - - lock (_cache) - { - if (_cache.ContainsKey(key)) - { - return _cache[key]; - } - - var ret = valueFactory(key); - _cache[key] = ret; - return ret; - } - } - } -} -#endif \ No newline at end of file diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index 61e5b9cb..6a870ebf 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -31,7 +31,7 @@ namespace Octokit.Internal #if HAS_SERVICEPOINTMANAGER // GitHub API requires TLS1.2 as of February 2018 - // + // // .NET Framework before 4.6 did not enable TLS1.2 by default // // Even though this is an AppDomain wide setting, the decision was made for Octokit to @@ -99,7 +99,7 @@ namespace Octokit.Internal object responseBody = null; string contentType = null; - // We added support for downloading images,zip-files and application/octet-stream. + // We added support for downloading images,zip-files and application/octet-stream. // Let's constrain this appropriately. var binaryContentTypes = new[] { AcceptHeaders.RawContentMediaType, diff --git a/Octokit/Http/HttpMessageHandlerFactory.cs b/Octokit/Http/HttpMessageHandlerFactory.cs index 5b9321c8..866d0540 100644 --- a/Octokit/Http/HttpMessageHandlerFactory.cs +++ b/Octokit/Http/HttpMessageHandlerFactory.cs @@ -19,17 +19,18 @@ namespace Octokit.Internal { AllowAutoRedirect = false }; -#if !PORTABLE + if (handler.SupportsAutomaticDecompression) { handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; } + if (handler.SupportsProxy && proxy != null) { handler.UseProxy = true; handler.Proxy = proxy; } -#endif + return handler; } } diff --git a/Octokit/Models/Request/RequestParameters.cs b/Octokit/Models/Request/RequestParameters.cs index de82010d..5e184c7a 100644 --- a/Octokit/Models/Request/RequestParameters.cs +++ b/Octokit/Models/Request/RequestParameters.cs @@ -1,13 +1,11 @@ using System; using System.Collections.Generic; +using System.Collections.Concurrent; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Reflection; using Octokit.Internal; -#if !PORTABLE -using System.Collections.Concurrent; -#endif namespace Octokit { @@ -16,13 +14,9 @@ namespace Octokit /// public abstract class RequestParameters { -#if PORTABLE - static readonly ConcurrentCache> _propertiesMap = - new ConcurrentCache>(); -#else static readonly ConcurrentDictionary> _propertiesMap = new ConcurrentDictionary>(); -#endif + /// /// Converts the derived object into a dictionary that can be used to supply query string parameters. ///