Pattern for detecting string(char, int) constructor
I'm struggling to get a pattern right, that would be able to detect an overloaded constructor call. The pattern should mark the following construtor call as an error, but it doesn't do so.
var s2 = new System.String( '1', 1 ); // String(char c, int count);
This is how the pattern looks like:
<Pattern Severity="ERROR" FormatAfterReplace="True" ShortenReferences="True" Language="CSHARP">
<Comment>Constructor Test 2</Comment>
<ReplacePattern IsNull="True" />
<SearchPattern>$type$( arg0, arg1 )</SearchPattern>
<Params />
<Placeholders>
<ExpressionPlaceholder Name="type" ExpressionType="System.String" ExactType="False" />
<ExpressionPlaceholder Name="arg0" ExpressionType="System.Char" ExactType="False" />
<ExpressionPlaceholder Name="arg1" ExpressionType="System.Int32" ExactType="False" />
</Placeholders>
</Pattern>
Any idea what I'm doing wrong?
Thanks in advance
Peter
Please sign in to leave a comment.
Hello Peter
Please try the following pattern:
new $type$($e1$, $e2$)
where $type$ is a type placeholder with type System.String
$e1$ is an expression placeholder with type System.Char
$e2$ is an expression placeholder with type System.Int32
Let me know if this helps. Thank you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Thanks, that did the trick!