C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

后端 未结 6 1964
無奈伤痛
無奈伤痛 2020-12-17 08:00

Not found it in StyleCop Help Manual, on SO and Google so here it is ;)

During StyleCop use I have a warning:

SA1121 - UseBuiltInTypeAlias -

6条回答
  •  忘掉有多难
    2020-12-17 08:26

    It would only really complicate the code if you had your own String, Int32 etc types which might end up being used instead of System.* - and please don't do that!

    Ultimately it's a personal preference. I use the aliases everywhere, but I know some people (e.g. Jeffrey Richter) advise never using them. It's probably a good idea to be consistent, that's all. If you don't like that StyleCop rule, disable it.

    Note that names of methods etc should use the framework name rather than the alias, so as to be language-neutral. This isn't so important for private / internal members, but you might as well have the same rules for private methods as public ones.

提交回复
热议问题