Replace Pattern should add an argument to method call but does nothing

Hi,

Writing a pattern to enforce specifying culture in parse methods (any existing?)

Search pattern:
$double$.Parse($arg$)

$arg$ - expression of System.String;
$double$ - System.Double type

Replace pattern:
$double$.Parse($arg$, System.Globalization.CultureInfo.InvariantCulture)

It finds all occurrences, there is a replace description ("Add invariant culture") in quick fix menu. But it does nothing, document flickers and remains the same.

What am I doing wrong?

Thanks

7 comments
Comment actions Permalink

Hello Vadim,

Could you please describe which ReSharper version do you use?

Thanks!

0
Comment actions Permalink

Here it is:

JetBrains ReSharper 7.0.1 C# Edition

Build 7.0.1098.2760 on 2012-08-27T13:31:12

License server at http://resharper.***.com:8080/licenseServer is used
Plugins: none
Visual Studio 11.0.50522.1.


Thanks.
0
Comment actions Permalink

Hello Vadim,

This pattern works fine for me. Could you please create and send me a small sample solution, which will demonstrate the issue? I beleive it can be happening only on some specific code/project/etc.

Thank you in advance!

0
Comment actions Permalink

Sure, see in attach..
Simple sln + screenshots.
Thanks for assist,
Vadim



Attachment(s):
AlmostNothing.7z.zip
0
Comment actions Permalink

One more question:

How to make this replacement work?

$Assert$.IsTrue($arg$) --> $arg$.Should().BeTrue("because ***");

<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/Comment/@EntryValue">Static test method are obsolete</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=arg/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=arg/Properties/=ExactType/@EntryIndexedValue">True</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=arg/Properties/=ExpressionType/@EntryIndexedValue">System.Boolean</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=arg/Type/@EntryValue">ExpressionPlaceholder</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=Assert/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=Assert/Properties/=ExactType/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=Assert/Properties/=ExpressionType/@EntryIndexedValue">Microsoft.VisualStudio.TestTools.UnitTesting.Assert</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/CustomPatternPlaceholder/=Assert/Type/@EntryValue">ExpressionPlaceholder</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/IsReplacePattern/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/LanguageName/@EntryValue">CSHARP</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/ReplaceComment/@EntryValue">Convert to Fluent notation</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/ReplacePattern/@EntryValue">$arg$.Should().BeTrue("because ***");</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=FE5985333A1A874FA04AA10C338B5905/SearchPattern/@EntryValue">$Assert$.IsTrue($arg$)</s:String>

0
Comment actions Permalink

Hello Vadim,

I apologize for a delayed response.
I've confirmed this issue as a bug and logged it here in YouTrack for further fixing: http://youtrack.jetbrains.com/issue/RSRP-336144.

Thank you.

0
Comment actions Permalink

Hello Vadim,

This pattern should work:

Search pattern (I beleive Assert can be searched directly without placeholder):
Assert.IsTrue($arg$);

Replace pattern:
$arg$.Should().BeTrue("because ***");

Please let me know if it works fine for you.
Thank you!

0

Please sign in to leave a comment.