This repository was archived by the owner on Nov 29, 2018. It is now read-only.
File tree 2 files changed +12
-6
lines changed
src/Microsoft.Framework.Localization
test/Microsoft.Framework.Localization.Test
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,9 @@ public class ResourceManagerStringLocalizer : IStringLocalizer
21
21
private readonly ConcurrentDictionary < string , object > _missingManifestCache =
22
22
new ConcurrentDictionary < string , object > ( ) ;
23
23
24
- private readonly ConcurrentDictionary < string , IList < string > > _resourceNamesCache =
24
+ private static readonly ConcurrentDictionary < string , IList < string > > _resourceNamesCache =
25
25
new ConcurrentDictionary < string , IList < string > > ( ) ;
26
-
27
-
26
+
28
27
/// <summary>
29
28
/// Creates a new <see cref="ResourceManagerStringLocalizer"/>.
30
29
/// </summary>
@@ -188,7 +187,9 @@ private IList<string> GetResourceNamesForCulture(CultureInfo culture)
188
187
}
189
188
resourceStreamName += ".resources" ;
190
189
191
- var cultureResourceNames = _resourceNamesCache . GetOrAdd ( resourceStreamName , key =>
190
+ var cacheKey = $ "assembly={ ResourceAssembly . FullName } ;resourceStreamName={ resourceStreamName } ";
191
+
192
+ var cultureResourceNames = _resourceNamesCache . GetOrAdd ( cacheKey , key =>
192
193
{
193
194
var names = new List < string > ( ) ;
194
195
using ( var cultureResourceStream = ResourceAssembly . GetManifestResourceStream ( key ) )
Original file line number Diff line number Diff line change @@ -22,15 +22,20 @@ public void EnumeratorCachesCultureWalk()
22
22
resourceAssembly . Setup ( rm => rm . GetManifestResourceStream ( It . IsAny < string > ( ) ) )
23
23
. Returns ( ( ) => MakeResourceStream ( ) ) ;
24
24
var baseName = "test" ;
25
- var localizer = new ResourceManagerStringLocalizer (
25
+ var localizer1 = new ResourceManagerStringLocalizer (
26
+ resourceManager . Object ,
27
+ resourceAssembly . Object ,
28
+ baseName ) ;
29
+ var localizer2 = new ResourceManagerStringLocalizer (
26
30
resourceManager . Object ,
27
31
resourceAssembly . Object ,
28
32
baseName ) ;
29
33
30
34
// Act
31
35
for ( int i = 0 ; i < 5 ; i ++ )
32
36
{
33
- localizer . ToList ( ) ;
37
+ localizer1 . ToList ( ) ;
38
+ localizer2 . ToList ( ) ;
34
39
}
35
40
36
41
// Assert
You can’t perform that action at this time.
0 commit comments