Trouble with replace in structural search pattern
Hi
I'm trying to make a replace pattern that replaces
new Mock<IFoo>().Object
with
Mock.Of<IFoo>()
but I can't get it to work; it finds the matching code fine, but the type is always empty when I replace so instead I get
Mock.Of<>()
I've tried several variations but haven't found a way to get this particular pattern to work even though similar ones do. Here's a pattern that I think should work:
<Pattern Severity="SUGGESTION">
<Comment>Use alternative syntax</Comment>
<ReplaceComment><![CDATA[Replace with shorter version]]></ReplaceComment>
<ReplacePattern><![CDATA[Mock.Of<$expected$>()]]></ReplacePattern>
<SearchPattern><![CDATA[new Mock<$expected$>().Object]]></SearchPattern>
<Params />
<Placeholders>
<TypePlaceholder Name="expected" Type="" ExactType="True" />
</Placeholders>
</Pattern>
Any ideas?
G.
Please sign in to leave a comment.
Related to http://youtrack.jetbrains.net/issue/RSRP-182435 ("Structural search and replace: Can't replace generic type constraints.") perhaps?
Maybe - not sure though.