Skip to content

Commit

Permalink
Obsolete ResourceManagerWithCultureStringLocalizer and WithCulture (d…
Browse files Browse the repository at this point in the history
…otnet/extensions#1133)

Obsolete ResourceManagerWithCultureStringLocalizer and WithCulture
\n\nCommit migrated from dotnet/extensions@924015e
  • Loading branch information
ryanbrandenburg authored Feb 20, 2019
1 parent 6bff217 commit 90eb71a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
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 Down Expand Up @@ -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 @@ -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,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)) { }
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

0 comments on commit 90eb71a

Please sign in to comment.