[corlib] Add check for collection modification during ForEach. Fixes #24775