Skip to content

Commit

Permalink
Remove [ThreadStatic] from MetaTypeElementUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
stakx committed Jul 6, 2017
1 parent b3ea5a3 commit 01d4085
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/Castle.Core/DynamicProxy/Generators/MetaTypeElementUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,20 @@ namespace Castle.DynamicProxy.Generators

internal static class MetaTypeElementUtil
{
[ThreadStatic]
private static StringBuilder sharedNameBuilder;

public static string CreateNameForExplicitImplementation(Type sourceType, string name)
{
if (sharedNameBuilder == null)
if (sourceType.GetTypeInfo().IsGenericType)
{
sharedNameBuilder = new StringBuilder();
var nameBuilder = new StringBuilder();
nameBuilder.AppendNameOf(sourceType);
nameBuilder.Append('.');
nameBuilder.Append(name);
return nameBuilder.ToString();
}
else
{
return string.Concat(sourceType.Name, ".", name);
}

var nameBuilder = sharedNameBuilder;
nameBuilder.Length = 0;
nameBuilder.AppendNameOf(sourceType);
nameBuilder.Append('.');
nameBuilder.Append(name);

return nameBuilder.ToString();
}

private static void AppendNameOf(this StringBuilder nameBuilder, Type type)
Expand Down

0 comments on commit 01d4085

Please sign in to comment.