I have a massive amount of repeating code that I wish to replace in the legacy code base and found Resharper's Structural Search and Replace feature to be a good match for the task. However I have problems making it match my patterns.
The pattern I wish to have quick-fixes for is:
public string PropertyName
{
get { return base.GetSubNode(_parameterNode, "ElementName").InnerText; }
set { base.GetSubNode(_parameterNode, "ElementName").InnerText = value; }
}
It's to be replaced with:
public string PropertyName
{
get { return GetProperty("ElementName"); }
set { SetProperty("ElementName", value); }
}
I created a pattern:
public string $propName$
{
get { return base.GetSubNode(_parameterNode, $elementName$).InnerText; }
set { base.GetSubNode(_parameterNode, $elementName$).InnerText = value; }
}
The pattern matches if i do a search, but does not result in a quick fix being available. If I instead create a separate pattern for the getter and setter I get quick fixes, but the getter pattern matches both the getter and the setter.
The getter pattern:
base.GetSubNode(_parameterNode, $elementName$).InnerText
How can I get quick-fixes for this getter/setter pair?
The following search/replace pattern works like a charm in ReSharper 6.1:
Save it to a .dotsettings file, and import to your ReSharper installation via ReSharper > Manage Options > [layer name] > Import/Export Settings > Import from file