diff --git a/Localization.sln b/Localization.sln index 695e03c..ad3a735 100644 --- a/Localization.sln +++ b/Localization.sln @@ -14,8 +14,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{7987 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalizationSample", "samples\LocalizationSample\LocalizationSample.csproj", "{55D9501F-15B9-4339-A0AB-6082850E5FCE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Extensions.Globalization.CultureInfoCache", "src\Microsoft.Extensions.Globalization.CultureInfoCache\Microsoft.Extensions.Globalization.CultureInfoCache.csproj", "{F3988D3A-A4C8-4FD7-BAFE-13E0D0A1659A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{B723DB83-A670-4BCB-95FB-195361331AD2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Extensions.Localization.Tests", "test\Microsoft.Extensions.Localization.Tests\Microsoft.Extensions.Localization.Tests.csproj", "{287AD58D-DF34-4F16-8616-FD78FA1CADF9}" diff --git a/src/Microsoft.AspNetCore.Localization/Microsoft.AspNetCore.Localization.csproj b/src/Microsoft.AspNetCore.Localization/Microsoft.AspNetCore.Localization.csproj index 0c58e73..19775dd 100644 --- a/src/Microsoft.AspNetCore.Localization/Microsoft.AspNetCore.Localization.csproj +++ b/src/Microsoft.AspNetCore.Localization/Microsoft.AspNetCore.Localization.csproj @@ -12,7 +12,6 @@ - diff --git a/src/Microsoft.Extensions.Globalization.CultureInfoCache/CultureInfoCache.cs b/src/Microsoft.Extensions.Globalization.CultureInfoCache/CultureInfoCache.cs deleted file mode 100644 index f9df733..0000000 --- a/src/Microsoft.Extensions.Globalization.CultureInfoCache/CultureInfoCache.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; - -namespace Microsoft.Extensions.Globalization -{ - /// - /// Provides read-only cached instances of . - /// - [Obsolete("This type is obsolete and will be removed in a future version.")] - public static class CultureInfoCache - { - private static readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); - - /// - /// Gets a read-only cached for the specified name. Only names that exist in - /// will be used. - /// - /// The culture name. - /// The cultures supported by the application. - /// - /// A read-only cached or null if a match wasn't found in - /// . - /// - public static CultureInfo GetCultureInfo(string name, IList supportedCultures) - { - // Allow only known culture names as this API is called with input from users (HTTP requests) and - // creating CultureInfo objects is expensive and we don't want it to throw either. - if (name == null || supportedCultures == null || - !supportedCultures.Any(supportedCulture => string.Equals(supportedCulture.Name, name, StringComparison.OrdinalIgnoreCase))) - { - return null; - } - - var entry = _cache.GetOrAdd(name, n => - { - try - { - return new CacheEntry(CultureInfo.ReadOnly(new CultureInfo(n))); - } - catch (CultureNotFoundException) - { - // This can still throw as the list of culture names we have is generated from latest .NET Framework - // on latest Windows and thus contains names that won't be supported on lower framework or OS versions. - // We can just cache the null result in these cases as it's ultimately bound by the list anyway. - return new CacheEntry(cultureInfo: null); - } - }); - - return entry.CultureInfo; - } - - private class CacheEntry - { - public CacheEntry(CultureInfo cultureInfo) - { - CultureInfo = cultureInfo; - } - - public CultureInfo CultureInfo { get; } - } - } -} diff --git a/src/Microsoft.Extensions.Globalization.CultureInfoCache/Microsoft.Extensions.Globalization.CultureInfoCache.csproj b/src/Microsoft.Extensions.Globalization.CultureInfoCache/Microsoft.Extensions.Globalization.CultureInfoCache.csproj deleted file mode 100644 index 7e77a57..0000000 --- a/src/Microsoft.Extensions.Globalization.CultureInfoCache/Microsoft.Extensions.Globalization.CultureInfoCache.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - Microsoft .NET Extensions - Provides cached instances of CultureInfo using a generated list of known culture names for use in scenarios where unbounded CultureInfo creation is undesirable. - netstandard1.1 - $(NoWarn);CS1591 - true - globalization;localization - - - diff --git a/src/Microsoft.Extensions.Globalization.CultureInfoCache/baseline.netcore.json b/src/Microsoft.Extensions.Globalization.CultureInfoCache/baseline.netcore.json deleted file mode 100644 index 0fe0083..0000000 --- a/src/Microsoft.Extensions.Globalization.CultureInfoCache/baseline.netcore.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.Extensions.Globalization.CultureInfoCache, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.Extensions.Globalization.CultureInfoCache", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetCultureInfo", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "supportedCultures", - "Type": "System.Collections.Generic.IList" - } - ], - "ReturnType": "System.Globalization.CultureInfo", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ] -} \ No newline at end of file