使用 ReSharper 或内置 IDE 功能对对象初始值设定项中的属性进行排序 [英] Sort Properties in an Object Initializer with ReSharper or Built-In IDE Features
本文介绍了使用 ReSharper 或内置 IDE 功能对对象初始值设定项中的属性进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定以下代码:
var x = new myObject() {
prop3 = 8,
prop1 = 5,
prop2 = 6
}
理想情况下,我想使用 ReSharper 或内置 IDE 功能对上面的属性进行排序,使它们看起来像这样:
Ideally, I would like to use ReSharper or built-in IDE features to sort the properties above so that they appear like this:
var x = new myObject() {
prop1 = 5,
prop2 = 6,
prop3 = 8
}
除此之外,我对轻量级扩展持开放态度——CodeMaid 太重了,并且与太多 ReSharper 函数重叠.
Outside of that, I'd be open to a lightweight extension--CodeMaid was way too heavy and overlaps with too many ReSharper functions.
推荐答案
您可以使用 Visual Studio 中的内置功能:
You can use the built-in feature in Visual Studio for this:
- 选择所有属性.
- 编辑 >高级 >排序行
不过,每个作业都必须在一行上.
Each assignment has to be on one single line though.
这篇关于使用 ReSharper 或内置 IDE 功能对对象初始值设定项中的属性进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文