Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force Resharper to use the CLR type names for auto-generated code?

According to the General Naming Conventions the usage of CLR type names (e.g. String, Int16) should be preferred over the usage of language specific type names (string, short). I usually follow this advice. Resharper however seems to use the language specific type names when generating code (refactorings like extract method, generating foreach loops, etc.) which is very annoying.

How can I force Resharper to use the CLR type names instead?

Update As many are wondering why someone would enforce a style where Int32 instead of int or String instead of string is used, the intention was better syntax highlighting: int is rendered as a keyword, Int32 is rendered as a type. As modifying the highlighting implementation seems overkill, enforcing CLR type simply does the job. That one of the reasons why this is part of our style guide.

like image 828
mbx Avatar asked Nov 04 '11 09:11

mbx


1 Answers

Open R# Options, go to C# Code Style. Or in more detail:

RESHARPER->Options

Code Editing->C#->Code Style

Build-in type naming->When referencing build-in type, prefer using choose CLR type name

This feature requires R#9.1 or higher.

If you are bound to older versions of ReSharper

There was an Extension for R#4.5-5.1 with exactly that purpose in mind. It's called Neovolve. Unfortunately this extension wasn't ported to any later R# versions.

VS 2015

Also for Visual Studio 2015 you may want to disable to prefer the intrinsic predefined types (which causes the symbols to be grayed out in the text editor) under Tools->Options Text Editor->C#->Code Style->Prefer intrinsic predefined type keyword*

like image 64
mbx Avatar answered Oct 13 '22 07:10

mbx