gpt4 book ai didi

c# - Visual Studio 2017 中的高级代码格式化

转载 作者:行者123 更新时间:2023-11-30 15:58:42 31 4
gpt4 key购买 nike

我正在寻找一种方法来获得更多在 Visual Studio 2017 中使用 C# 格式化代码的可能性,经过几天的谷歌搜索,我觉得这似乎是我可以找到答案的地方。

我们正在寻找的功能是将代码分配放入一个 block 中,例如

public Foo(string name, string adress, int numberOfBooksOwned)
{
Name = name;
Adress = adress;
NumberOfBooksOwned = numberOfBooksOwned;
}

成为

public Foo(string name, string adress, int numberOfBooksOwned)
{
Name = name;
Adress = adress;
NumberOfBooksOwned = numberOfBooksOwned;
}

它还应该能够覆盖 Visual Studio 提供的所有格式化可能性,并将它们保存到任何类型的文件中,以便我团队的其他成员也可以使用这些设置。

我知道 VS 2017 添加了一种新的代码格式,但如果我做对了,添加了对 EditorConfig 的支持没有做我需要的。

我也试过CodeMaid,但是这个好像对性能要求很高,我也觉得不符合我的需求。

有没有人知道符合上述描述的东西,最好是与 Visual Studio 2017 兼容的某种扩展或自最新版本以来内置的东西,以便任何人使用。

提前致谢,
马库斯

最佳答案

我相信我无意中为您找到了答案。 Microsoft 将其添加到 VS2017 的 Productivity PowerTools。 https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.AlignAssignments允许您通过按 Ctrl+Alt+]

完全按照您的示例显示

请务必记下页面中的一条评论:

Note! This may conflict with your formatting settings. E.g. in C# you will need to disable: Tools->Options->Text Editor->C#->Formatting->Spacing->"Ignore spaces in declaration statements"

考虑到这是 Microsoft 添加的扩展,我想可以肯定地说此功能未内置到 VS2017 中。

关于c# - Visual Studio 2017 中的高级代码格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42715261/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com