New CodeRush Plugin – Convert String to AppSetting

A customer recently tweeted:

Any chance of a CodeRush plugin to convert a literal to a config (app.config) setting? pretty please

Well when the request is so polite, it’s hard to say no Smile

The Convert String to AppSetting plugin adds a new Refactoring to your standard arsenal.

Simply…

  • Place your caret on the string in question.

    ConvertStringToAppSettingBefore
  • Hit your CodeRush \ Refactor key ( Defaults to Ctrl+` )
  • Choose Convert String to AppSetting from the list of refactorings.

    ConvertStringToAppSettingMenu

CodeRush will…

  • Create a new App.config file if one doesn’t already exist.
  • Add a new setting deriving it’s name from the text of your initial string.

    ConvertStringToAppSettingAppConfig
  • Replace the original string with a call to ConfigurationManager.AppSettings

    ConvertStringToAppSettingAfter
  • Link the key-text of your new setting with that of the call, so that you can easily rename them as one.

So where can I get this wonderful plugin?

This plugin is available in 2 locations

GitHub: From here you can get the current (and historical) source of the plugin as well as the latest installable version.

The Visual Studio Gallery: Installing from the Visual Studio Gallery provides the added bonus of VS being on the lookout for any updates that are shipped on your behalf.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.