Visual Studio 2015 - Code style settings

2019-01-23 02:33发布

In the new Visual Studio 2015 I get the following "Name can be simplified" quick action. I prefer using String over string when using the static methods of the String class because gives a better overview.

I have looked for an option to customize this under: TOOLS -> Options -> Text Editor -> C# -> Code Style, but there was not much there.

Is there anyway I can customize this settings? Or even better if I can customize these settings for everyone working on the solution/project? So everyone uses the same coding style.

2条回答
劫难
2楼-- · 2019-01-23 02:59

You can now add .editorconfig file and opt-out intrinsic predefined type keyword for expressions:

dotnet_style_predefined_type_for_member_access = false:warning

Here is a reference file from Roslyn repo.

查看更多
戒情不戒烟
3楼-- · 2019-01-23 03:01

I just came across this myself and agree on String vs string for static methods. I think you were correct in looking in TOOLS -> Options -> Text Editor -> C# -> Code Style, because I unticked "Prefer intrinsic predefined type keyword in member access expressions" and this got rid of the "Name can be simplified" message that I was experiencing.

Did you try this or are you looking to have more control over the customisations?

查看更多
登录 后发表回答