提交 1d7ac2ab 编写于 作者: D Dustin Campbell

Fix FileCodeModel's usage of CleanableWeakComHandleTable when an a key is in...

Fix FileCodeModel's usage of CleanableWeakComHandleTable when an a key is in the table but the value is null
上级 97f67587
......@@ -197,11 +197,11 @@ public TValue Remove(TKey key)
_deadKeySet.Remove(key);
}
TValue value;
if (TryGetValue(key, out value))
WeakComHandle<TValue, TValue> handle;
if (_table.TryGetValue(key, out handle))
{
_table.Remove(key);
return value;
return handle.ComAggregateObject;
}
return null;
......@@ -215,7 +215,7 @@ public bool TryGetValue(TKey key, out TValue value)
if (_table.TryGetValue(key, out handle))
{
value = handle.ComAggregateObject;
return value != null;
return true;
}
value = null;
......
......@@ -206,20 +206,21 @@ internal T GetOrCreateCodeElement<T>(SyntaxNode node)
EnvDTE.CodeElement codeElement;
if (_codeElementTable.TryGetValue(nodeKey, out codeElement))
{
var element = ComAggregate.TryGetManagedObject<AbstractCodeElement>(codeElement);
if (element.IsValidNode())
if (codeElement != null)
{
if (codeElement is T)
var element = ComAggregate.TryGetManagedObject<AbstractCodeElement>(codeElement);
if (element.IsValidNode())
{
return (T)codeElement;
}
if (codeElement is T)
{
return (T)codeElement;
}
throw new InvalidOperationException($"Found a valid code element for {nodeKey}, but it is not of type, {typeof(T).ToString()}");
}
else
{
_codeElementTable.Remove(nodeKey);
throw new InvalidOperationException($"Found a valid code element for {nodeKey}, but it is not of type, {typeof(T).ToString()}");
}
}
_codeElementTable.Remove(nodeKey);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册