-
Notifications
You must be signed in to change notification settings - Fork 480
Fix the bug that when delegate is used there will be a KeyNotFoundException. #2686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| results.Add(methodSymbol, new HashSet<ISymbol>()); | ||
| Debug.Assert(callGraph.Keys.Contains(methodSymbol), methodSymbol.Name + "was not present in the dictionary."); | ||
|
|
||
| foreach (var child in callGraph[methodSymbol].Keys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of just a Debug.Assert(), we could also gracefully handle missing keys in retail builds.
if (!callGraph.TryGetValue(methodSymbol, out var calledMethods))
{
Debug.Fail(methodSymbol.Name + " was not found in callGraph");
return;
}
foreach (var child in calledMethods.Keys)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
| results[methodSymbol].UnionWith(results[child]); | ||
| } | ||
| FindCalledDangerousMethod(child, visited, results); | ||
| Debug.Assert(results.Keys.Contains(child), child.Name + "was not present in the dictionary."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug.Assert(results.Keys.Contains(child), child.Name + "was not present in the dictionary."); [](start = 32, length = 94)
Same thing here.
| return; | ||
| } | ||
|
|
||
| results[methodSymbol].UnionWith(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here, instead of returning, you could just ignore that particular child if it's not found:
if (results.TryGetValue(child, out var result))
{
results[methodSymbol].UnionWith(result);
}
else
{
Debug.Fail(child.Name + " was not found in callGraph");
}
dotpaul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
No description provided.