Fix issue when adding/removing event handlers again and again
An issue has existing for a long while that is caused by Code Model. The repro looks something like this: 1. Double-click a Button to generate a Click event handler. 2. Undo 3. Double-click the Button again. The XAML designer team is now running into this as well, so a fix is definitely overdue. The issue here has to do with the cache of COM objects that Code Model maintains. Essentially, when a new `CodeElement` is added to the cache, we need to first check to see if there's an element already in the cache with the same key. If there, is, we now remove the original element from the cache before adding the new one. If somebody still has a reference to the original `CodeElement`, it'll still continue to function since it points to a valid syntax node key.
Showing
想要评论请 注册 或 登录