2

I have lots of code such as:

Resources.SettingName.ResourceManager.GetString("Setting")

which can be easily written as:

SettingName.Setting

I've been trying to write a custom pattern in Resharper to achieve this, but haven't succeeded yet. Could somebody tell me what would be the right pattern?

ps: i use resharper 6.

2
  • I've tried different placeholders (argument, type, expression etc) but none of them worked. Commented May 22, 2012 at 11:46
  • I guess you can build a Search pattern but not a Replace pattern, right? Commented May 22, 2012 at 13:31

1 Answer 1

2

You could use Visual Studio's Quick Find and Replace using Regular expressions:

Find What:

Resources\.{.+}\.ResourceManager\.GetString\("{.+}"\)

Replace with:

\1.\2

This assumes that your pattern conforms to: Resources.{some setting name}.ResourceManager.SetString("{some setting}")

Sign up to request clarification or add additional context in comments.

2 Comments

I finally went with this solution. Also recorded it as a macro and bound it to a keyboard shortcut. The replace bit actually had to be \1.\2. Thanks.
@VishalShah - I have corrected this, not sure why I thought they were the other way around, anyway, it's good that it helped you achieve your results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.