[英]Autocompleting initializer with Resharper 6 in Visual Studio 2010
I was wondering if there is any way to shortcut the process of object initialization with VS 2010 and Resharper (6).我想知道是否有任何方法可以使用 VS 2010 和 Resharper (6) 来缩短 object 初始化的过程。 When presented with the yellow tool tip below I'd like to have it create an assignment for each field.
当出现下面的黄色工具提示时,我想让它为每个字段创建一个分配。
For instance, it would generate:例如,它将生成:
Contact =;联系方式=; ContactId =;
联系人 ID =; CreateDate =;
创建日期 =; etc, etc
等等等等
(one for each property). (每个属性一个)。
ReSharper code completion works exactly this way. ReSharper 代码完成正是以这种方式工作的。 As soon as you've typed in the braces, press Ctrl+Space to get the list of all properties:
输入大括号后,立即按 Ctrl+Space 以获取所有属性的列表:
var data = new Data {|}
Then, after entering a comma to delimit properties, ReSharper completion will only show properties that you haven't yet initialized.然后,在输入逗号分隔属性后,ReSharper 补全将仅显示您尚未初始化的属性。 More importantly, when you complete a property name, it inserts the property and the equals sign.
更重要的是,当您完成一个属性名称时,它会插入该属性和等号。
Still not answered satisfactorily in another (duplicate) question: Is there a way, at design time, to initialize an object with all properties in Visual Studio 2010?在另一个(重复)问题中仍然没有得到令人满意的回答: 在设计时有没有办法用 Visual Studio 2010 中的所有属性初始化 object?
Closest answer would be to create a custom Code Snippet or Resharper Live Template, but I only see a macro that triggers "smart completion", which is the CTRL+SPACE
suggestion seen elsewhere.最接近的答案是创建自定义代码片段或 Resharper 实时模板,但我只看到一个触发“智能完成”的宏,这是在其他地方看到的
CTRL+SPACE
建议。 I'm offering this incomplete answer in case it's easier to remember an alias rather than a shortcut key.我提供了这个不完整的答案,以防记住别名而不是快捷键更容易。
I'd still like it to perform smart completion on that popup list, which is really what the question is asking for.我仍然希望它在该弹出列表上执行智能完成,这确实是问题所要求的。 You might also be able to create a custom macro that will accomplish this.
您也许还可以创建一个自定义宏来完成此操作。
(I'll keep looking and update this answer if I find anything.) (如果我发现任何东西,我会继续寻找并更新这个答案。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.