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.
2 comments
Comment actions Permalink

Related to http://youtrack.jetbrains.net/issue/RSRP-182435 ("Structural search and replace: Can't replace generic type constraints.") perhaps?

0
Comment actions Permalink

Maybe - not sure though.

0

Please sign in to leave a comment.