diff --git a/src/Localization/Abstractions/ref/Microsoft.Extensions.Localization.Abstractions.netstandard2.0.cs b/src/Localization/Abstractions/ref/Microsoft.Extensions.Localization.Abstractions.netstandard2.0.cs index b18cec35f88..3f9f422021a 100644 --- a/src/Localization/Abstractions/ref/Microsoft.Extensions.Localization.Abstractions.netstandard2.0.cs +++ b/src/Localization/Abstractions/ref/Microsoft.Extensions.Localization.Abstractions.netstandard2.0.cs @@ -8,6 +8,7 @@ public partial interface IStringLocalizer Microsoft.Extensions.Localization.LocalizedString this[string name] { get; } Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get; } System.Collections.Generic.IEnumerable GetAllStrings(bool includeParentCultures); + [System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture); } public partial interface IStringLocalizerFactory @@ -42,6 +43,7 @@ public StringLocalizer(Microsoft.Extensions.Localization.IStringLocalizerFactory public virtual Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } } public virtual Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } } public System.Collections.Generic.IEnumerable GetAllStrings(bool includeParentCultures) { throw null; } + [System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] public virtual Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture) { throw null; } } } diff --git a/src/Localization/Abstractions/src/IStringLocalizer.cs b/src/Localization/Abstractions/src/IStringLocalizer.cs index 0e1145bbcab..cabdf434ac4 100644 --- a/src/Localization/Abstractions/src/IStringLocalizer.cs +++ b/src/Localization/Abstractions/src/IStringLocalizer.cs @@ -1,6 +1,7 @@ -// 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. +// 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.Generic; using System.Globalization; @@ -40,6 +41,7 @@ public interface IStringLocalizer /// /// The to use. /// A culture-specific . + [Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] IStringLocalizer WithCulture(CultureInfo culture); } -} \ No newline at end of file +} diff --git a/src/Localization/Abstractions/src/StringLocalizerOfT.cs b/src/Localization/Abstractions/src/StringLocalizerOfT.cs index 131c1126ec3..4190ca14ffc 100644 --- a/src/Localization/Abstractions/src/StringLocalizerOfT.cs +++ b/src/Localization/Abstractions/src/StringLocalizerOfT.cs @@ -1,5 +1,5 @@ -// 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. +// 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.Generic; @@ -30,6 +30,7 @@ public StringLocalizer(IStringLocalizerFactory factory) } /// + [Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] public virtual IStringLocalizer WithCulture(CultureInfo culture) => _localizer.WithCulture(culture); /// @@ -64,4 +65,4 @@ public virtual LocalizedString this[string name] public IEnumerable GetAllStrings(bool includeParentCultures) => _localizer.GetAllStrings(includeParentCultures); } -} \ No newline at end of file +} diff --git a/src/Localization/Localization/ref/Microsoft.Extensions.Localization.netstandard2.0.cs b/src/Localization/Localization/ref/Microsoft.Extensions.Localization.netstandard2.0.cs index 7bbe1797a5b..80175da7184 100644 --- a/src/Localization/Localization/ref/Microsoft.Extensions.Localization.netstandard2.0.cs +++ b/src/Localization/Localization/ref/Microsoft.Extensions.Localization.netstandard2.0.cs @@ -36,6 +36,7 @@ public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceM public virtual System.Collections.Generic.IEnumerable GetAllStrings(bool includeParentCultures) { throw null; } protected System.Collections.Generic.IEnumerable GetAllStrings(bool includeParentCultures, System.Globalization.CultureInfo culture) { throw null; } protected string GetStringSafely(string name, System.Globalization.CultureInfo culture) { throw null; } + [System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] public Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture) { throw null; } } public partial class ResourceManagerStringLocalizerFactory : Microsoft.Extensions.Localization.IStringLocalizerFactory @@ -51,6 +52,7 @@ public ResourceManagerStringLocalizerFactory(Microsoft.Extensions.Options.IOptio protected virtual string GetResourcePrefix(string location, string baseName, string resourceLocation) { throw null; } protected virtual Microsoft.Extensions.Localization.RootNamespaceAttribute GetRootNamespaceAttribute(System.Reflection.Assembly assembly) { throw null; } } + [System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] public partial class ResourceManagerWithCultureStringLocalizer : Microsoft.Extensions.Localization.ResourceManagerStringLocalizer { public ResourceManagerWithCultureStringLocalizer(System.Resources.ResourceManager resourceManager, System.Reflection.Assembly resourceAssembly, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, System.Globalization.CultureInfo culture, Microsoft.Extensions.Logging.ILogger logger) : base (default(System.Resources.ResourceManager), default(System.Reflection.Assembly), default(string), default(Microsoft.Extensions.Localization.IResourceNamesCache), default(Microsoft.Extensions.Logging.ILogger)) { } diff --git a/src/Localization/Localization/src/ResourceManagerStringLocalizer.cs b/src/Localization/Localization/src/ResourceManagerStringLocalizer.cs index e2e1a3f234f..90f8e077b42 100644 --- a/src/Localization/Localization/src/ResourceManagerStringLocalizer.cs +++ b/src/Localization/Localization/src/ResourceManagerStringLocalizer.cs @@ -1,5 +1,5 @@ -// 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. +// 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; @@ -151,6 +151,7 @@ public virtual LocalizedString this[string name] /// /// The to use. /// A culture-specific . + [Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] public IStringLocalizer WithCulture(CultureInfo culture) { return culture == null @@ -271,4 +272,4 @@ private IEnumerable GetResourceNamesFromCultureHierarchy(CultureInfo sta return resourceNames; } } -} \ No newline at end of file +} diff --git a/src/Localization/Localization/src/ResourceManagerWithCultureStringLocalizer.cs b/src/Localization/Localization/src/ResourceManagerWithCultureStringLocalizer.cs index 65b6ae242c6..2bc51289da1 100644 --- a/src/Localization/Localization/src/ResourceManagerWithCultureStringLocalizer.cs +++ b/src/Localization/Localization/src/ResourceManagerWithCultureStringLocalizer.cs @@ -1,5 +1,5 @@ -// 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. +// 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.Generic; @@ -15,6 +15,7 @@ namespace Microsoft.Extensions.Localization /// An that uses the and /// to provide localized strings for a specific . /// + [Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] public class ResourceManagerWithCultureStringLocalizer : ResourceManagerStringLocalizer { private readonly string _resourceBaseName; @@ -161,4 +162,4 @@ public override LocalizedString this[string name] public override IEnumerable GetAllStrings(bool includeParentCultures) => GetAllStrings(includeParentCultures, _culture); } -} \ No newline at end of file +} diff --git a/src/Localization/Localization/test/ResourceManagerStringLocalizerTest.cs b/src/Localization/Localization/test/ResourceManagerStringLocalizerTest.cs index ff7bfa9933d..a82ce9d1d39 100644 --- a/src/Localization/Localization/test/ResourceManagerStringLocalizerTest.cs +++ b/src/Localization/Localization/test/ResourceManagerStringLocalizerTest.cs @@ -182,12 +182,11 @@ public void ResourceManagerStringLocalizer_GetAllStrings_MissingResourceThrows(b var resourceManager = new TestResourceManager(baseName, resourceAssembly); var logger = Logger; - var localizer = new ResourceManagerWithCultureStringLocalizer( + var localizer = new ResourceManagerStringLocalizer( resourceManager, resourceAssembly.Assembly, baseName, resourceNamesCache, - CultureInfo.CurrentCulture, logger); // Act & Assert @@ -291,7 +290,7 @@ public TestAssemblyWrapper(Type type) public override Stream GetManifestResourceStream(string name) { ManifestResourceStreamCallCount++; - + return HasResources ? MakeResourceStream() : null; } }