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

Remove Obsoleted methods for 5.0 #2562

Merged
merged 2 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all 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,8 +8,6 @@ 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 Down Expand Up @@ -43,7 +41,5 @@ 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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ 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 Down Expand Up @@ -43,7 +41,5 @@ 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: 0 additions & 8 deletions src/Localization/Abstractions/src/IStringLocalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,5 @@ public interface IStringLocalizer
/// </param>
/// <returns>The strings.</returns>
IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures);

/// <summary>
/// Creates a new <see cref="IStringLocalizer"/> for a specific <see cref="CultureInfo"/>.
/// </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);
}
}
4 changes: 0 additions & 4 deletions src/Localization/Abstractions/src/StringLocalizerOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ public StringLocalizer(IStringLocalizerFactory factory)
_localizer = factory.Create(typeof(TResourceSource));
}

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

/// <inheritdoc />
public virtual LocalizedString this[string name]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ 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 @@ -52,14 +50,6 @@ 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 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; }
}
public partial class ResourceNamesCache : Microsoft.Extensions.Localization.IResourceNamesCache
{
public ResourceNamesCache() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ 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 @@ -52,14 +50,6 @@ 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 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; }
}
public partial class ResourceNamesCache : Microsoft.Extensions.Localization.IResourceNamesCache
{
public ResourceNamesCache() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,30 +146,6 @@ public virtual LocalizedString this[string name]
}
}

/// <summary>
/// Creates a new <see cref="ResourceManagerStringLocalizer"/> for a specific <see cref="CultureInfo"/>.
/// </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
? new ResourceManagerStringLocalizer(
_resourceManager,
_resourceStringProvider,
_resourceBaseName,
_resourceNamesCache,
_logger)
: new ResourceManagerWithCultureStringLocalizer(
_resourceManager,
_resourceStringProvider,
_resourceBaseName,
_resourceNamesCache,
culture,
_logger);
}

/// <inheritdoc />
public virtual IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) =>
GetAllStrings(includeParentCultures, CultureInfo.CurrentUICulture);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,6 @@ public void Constructor_ResolvesLocalizerFromFactory()
factory.Verify(mock => mock.Create(typeof(object)), Times.Once());
}

[Fact]
public void WithCulture_InvokesWithCultureFromInnerLocalizer()
{
// Arrange
var factory = new Mock<IStringLocalizerFactory>();
var innerLocalizer = new Mock<IStringLocalizer>();
factory.Setup(mock => mock.Create(typeof(object)))
.Returns(innerLocalizer.Object);

var localizer = new StringLocalizer<object>(factory.Object);

// Act
#pragma warning disable CS0618
localizer.WithCulture(CultureInfo.GetCultureInfo("fr-FR"));
#pragma warning restore CS0618

// Assert
#pragma warning disable CS0618
innerLocalizer.Verify(mock => mock.WithCulture(CultureInfo.GetCultureInfo("fr-FR")), Times.Once());
#pragma warning restore CS0618
}

[Fact]
public void Indexer_ThrowsAnExceptionForNullName()
{
Expand Down