简体   繁体   English

如何在代码中找到所有特定类型的对象初始化

[英]How to find all particular type object initilializations in code

When refactoring a good piece of code I ran into the problem: I have to find and check all places where new instances of a particular type of object are created.在重构一段好的代码时,我遇到了问题:我必须查找并检查创建特定类型对象的新实例的所有位置。 Whether it is: methods, constructors, 'new' keyword.无论是:方法、构造函数、'new'关键字。 I can't do it without checking all references to the class with CodeLens, but there are too many references!如果不使用 CodeLens 检查对类的所有引用,我就无法做到这一点,但是引用太多了!

好的,感谢对本节发表评论的人,找到了解决方案,而且很简单:创建无参数的构造函数 - 您可以使用任何带有 CodeLens 的构造函数导航到所有对象创建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM