提交 62005101 编写于 作者: S Sam Harwell

Use ConcurrentDictionary instead of ConditionalWeakTable

上级 1a03019d
......@@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Roslyn.Utilities;
......@@ -259,8 +258,8 @@ public void OnRemoved()
private sealed class AnalyzerTypeData
{
private const string UserDiagnosticsPrefixTableName = "<UserDiagnostics2>";
private static readonly ConditionalWeakTable<Type, AnalyzerTypeData> s_analyzerTypeData
= new ConditionalWeakTable<Type, AnalyzerTypeData>();
private static readonly ConcurrentDictionary<Type, AnalyzerTypeData> s_analyzerTypeData
= new ConcurrentDictionary<Type, AnalyzerTypeData>();
private AnalyzerTypeData(Type type)
{
......@@ -282,7 +281,7 @@ private AnalyzerTypeData(Type type)
public static AnalyzerTypeData ForType(Type type)
{
return s_analyzerTypeData.GetValue(type, t => new AnalyzerTypeData(t));
return s_analyzerTypeData.GetOrAdd(type, t => new AnalyzerTypeData(t));
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册