简体   繁体   English

在 Visual Studio 2010 中使用 Resharper 6 自动完成初始化程序

[英]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). (每个属性一个)。

http://imgur.com/Cd5V7

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.

相关问题 Nunit 2.6 + Resharper 7 + NCrunch + visual studio 2010 - Nunit 2.6 + Resharper 7 +NCrunch + visual studio 2010 Visual Studio 2010 + resharper 括号缩进问题 - Visual studio 2010 + resharper bracket indentation problem visual studio中自动完成属性的快捷方式? - Shortcut for autocompleting properties in visual studio? Visual Studio Professional 2010:停止将“new {”从自动填充到“new object {”(C#) - Visual Studio Professional 2010: Stop “new {” from autocompleting into “new object {” (C#) 无法在Visual Studio 2010 + Resharper中键入某些方括号 - Can't type certain square brackets in Visual Studio 2010 + Resharper 使用Visual Studio 2008/2010或Resharper 5创建自动属性的快捷方式 - Shortcut to create automatic properties using Visual Studio 2008/2010 or Resharper 5 ReSharper和Visual Studio 2008 - ReSharper and Visual Studio 2008 编写Visual Studio 2010插件,想在代码编辑器中显示像Resharper这样的工具箱 - Writing Visual Studio 2010 Plugin, would like to show a toolbox like Resharper in code editor 我们可以配置Visual Studio 2010或Resharper 7.1自动创建空的类/函数/等注释吗? - Can we configure Visual Studio 2010 or Resharper 7.1 to create automatically empty class / function / etc comments? Visual Studio 2010:使用ReSharper代码分析后执行C#项目时出错 - Visual Studio 2010 : Error when executing the C# Project after code-analyzing with ReSharper
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM