Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obsolete ResourceManagerWithCultureStringLocalizer and WithCulture #1133

Merged
merged 4 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Microsoft.Extensions.Localization.LocalizedString> 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
Expand All @@ -27,7 +28,7 @@ public LocalizedString(string name, string value, bool resourceNotFound, string
public bool ResourceNotFound { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string SearchedLocation { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public static implicit operator string (Microsoft.Extensions.Localization.LocalizedString localizedString) { throw null; }
public static implicit operator string(Microsoft.Extensions.Localization.LocalizedString localizedString) { throw null; }
public override string ToString() { throw null; }
}
public static partial class StringLocalizerExtensions
Expand All @@ -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<Microsoft.Extensions.Localization.LocalizedString> 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; }
}
}
8 changes: 5 additions & 3 deletions src/Localization/Abstractions/src/IStringLocalizer.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -40,6 +41,7 @@ public interface IStringLocalizer
/// </summary>
/// <param name="culture">The <see cref="CultureInfo"/> to use.</param>
/// <returns>A culture-specific <see cref="IStringLocalizer"/>.</returns>
[Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
IStringLocalizer WithCulture(CultureInfo culture);
}
}
}
7 changes: 4 additions & 3 deletions src/Localization/Abstractions/src/StringLocalizerOfT.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -30,6 +30,7 @@ public StringLocalizer(IStringLocalizerFactory factory)
}

/// <inheritdoc />
[Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public virtual IStringLocalizer WithCulture(CultureInfo culture) => _localizer.WithCulture(culture);

/// <inheritdoc />
Expand Down Expand Up @@ -64,4 +65,4 @@ public virtual LocalizedString this[string name]
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) =>
_localizer.GetAllStrings(includeParentCultures);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class LocalizationOptions
public LocalizationOptions() { }
public string ResourcesPath { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
public partial class ResourceLocationAttribute : System.Attribute
{
public ResourceLocationAttribute(string resourceLocation) { }
Expand All @@ -36,6 +36,7 @@ public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceM
public virtual System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
protected System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> 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
Expand All @@ -51,9 +52,10 @@ 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)) { }
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)) { }
public override Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } }
public override Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } }
public override System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
Expand All @@ -63,7 +65,7 @@ public partial class ResourceNamesCache : Microsoft.Extensions.Localization.IRes
public ResourceNamesCache() { }
public System.Collections.Generic.IList<string> GetOrAdd(string name, System.Func<string, System.Collections.Generic.IList<string>> valueFactory) { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
public partial class RootNamespaceAttribute : System.Attribute
{
public RootNamespaceAttribute(string rootNamespace) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -151,6 +151,7 @@ public virtual LocalizedString this[string name]
/// </summary>
/// <param name="culture">The <see cref="CultureInfo"/> to use.</param>
/// <returns>A culture-specific <see cref="ResourceManagerStringLocalizer"/>.</returns>
[Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public IStringLocalizer WithCulture(CultureInfo culture)
{
return culture == null
Expand Down Expand Up @@ -271,4 +272,4 @@ private IEnumerable<string> GetResourceNamesFromCultureHierarchy(CultureInfo sta
return resourceNames;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,6 +15,7 @@ namespace Microsoft.Extensions.Localization
/// An <see cref="IStringLocalizer"/> that uses the <see cref="ResourceManager"/> and
/// <see cref="ResourceReader"/> to provide localized strings for a specific <see cref="CultureInfo"/>.
/// </summary>
[Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public class ResourceManagerWithCultureStringLocalizer : ResourceManagerStringLocalizer
{
private readonly string _resourceBaseName;
Expand Down Expand Up @@ -161,4 +162,4 @@ public override LocalizedString this[string name]
public override IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) =>
GetAllStrings(includeParentCultures, _culture);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -291,7 +290,7 @@ public TestAssemblyWrapper(Type type)
public override Stream GetManifestResourceStream(string name)
{
ManifestResourceStreamCallCount++;

return HasResources ? MakeResourceStream() : null;
}
}
Expand Down