@@ -220,33 +220,35 @@ public static IEnumerable<Declaration> FindEventHandlers(this IEnumerable<Declar
220220 && declaration . IdentifierName . StartsWith ( control . IdentifierName + "_" ) ) ;
221221 }
222222
223- public static IEnumerable < Declaration > FindBuiltInEventHandlers ( this List < Declaration > declarations )
223+ public static IEnumerable < Declaration > FindBuiltInEventHandlers ( this IEnumerable < Declaration > declarations )
224224 {
225- var handlerNames = declarations . Where ( declaration => declaration . IsBuiltIn && declaration . DeclarationType == DeclarationType . Event )
225+ var declarationList = declarations . ToList ( ) ;
226+
227+ var handlerNames = declarationList . Where ( declaration => declaration . IsBuiltIn && declaration . DeclarationType == DeclarationType . Event )
226228 . Select ( e => e . ParentDeclaration . IdentifierName + "_" + e . IdentifierName ) ;
227229
228230 // class module built-in events
229- var classModuleHandlers = declarations . Where ( item =>
231+ var classModuleHandlers = declarationList . Where ( item =>
230232 item . DeclarationType == DeclarationType . Procedure &&
231233 item . ParentDeclaration . DeclarationType == DeclarationType . ClassModule &&
232234 ( item . IdentifierName == "Class_Initialize" || item . IdentifierName == "Class_Terminate" ) ) ;
233235
234236 // user form built-in events
235- var userFormHandlers = declarations . Where ( item =>
237+ var userFormHandlers = declarationList . Where ( item =>
236238 item . DeclarationType == DeclarationType . Procedure &&
237239 item . ParentDeclaration . DeclarationType == DeclarationType . ClassModule &&
238240 item . QualifiedName . QualifiedModuleName . Component . Type == vbext_ComponentType . vbext_ct_MSForm &&
239241 new [ ]
240242 {
241243 "UserForm_Activate" , "UserForm_AddControl" , "UserForm_BeforeDragOver" , "UserForm_BeforeDropOrPaste" ,
242- "UserForm_Click" , "UserForm_DblCIick " , "UserForm_Deactivate" , "UserForm_Error" ,
244+ "UserForm_Click" , "UserForm_DblClick " , "UserForm_Deactivate" , "UserForm_Error" ,
243245 "UserForm_Initialize" , "UserForm_KeyDown" , "UserForm_KeyPress" , "UserForm_KeyUp" , "UserForm_Layout" ,
244246 "UserForm_MouseDown" , "UserForm_MouseMove" , "UserForm_MouseUp" , "UserForm_QueryClose" ,
245247 "UserForm_RemoveControl" , "UserForm_Resize" , "UserForm_Scroll" , "UserForm_Terminate" ,
246248 "UserForm_Zoom"
247249 } . Contains ( item . IdentifierName ) ) ;
248250
249- var handlers = declarations . Where ( declaration => ! declaration . IsBuiltIn
251+ var handlers = declarationList . Where ( declaration => ! declaration . IsBuiltIn
250252 && declaration . DeclarationType == DeclarationType . Procedure
251253 && handlerNames . Contains ( declaration . IdentifierName ) ) . ToList ( ) ;
252254
0 commit comments