<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nithin V Rajendrakumar</title>
    <description>The latest articles on DEV Community by Nithin V Rajendrakumar (@vr_nithin).</description>
    <link>https://dev.to/vr_nithin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F20083%2Fb5dd1da0-38f1-4499-b57d-94f07eb5280c.jpg</url>
      <title>DEV Community: Nithin V Rajendrakumar</title>
      <link>https://dev.to/vr_nithin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vr_nithin"/>
    <language>en</language>
    <item>
      <title>Swap Parameters in Visual Studio using Regular Expression</title>
      <dc:creator>Nithin V Rajendrakumar</dc:creator>
      <pubDate>Wed, 28 Feb 2018 06:04:55 +0000</pubDate>
      <link>https://dev.to/vr_nithin/swap-parameters-in-visual-studio-using-regular-expression--186g</link>
      <guid>https://dev.to/vr_nithin/swap-parameters-in-visual-studio-using-regular-expression--186g</guid>
      <description>&lt;p&gt;This issue occurs to me many times while sending a review request, For example when I use Assert.AreEqual() method and the parameters are not in the order ( expected value, actual value) is got swapped. It's boring and long vexing job to correct all the Assert.AreEqual() parameter order. While searching on the Internet found this easy way to swap the parameters using Regular Expression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// One of the common place to swap parmeter&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;AreEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="n"&gt;actual&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, I wrote code like :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;Assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AreEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ActualString1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CretedString1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;Assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AreEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ActualString2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CretedString2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="n"&gt;Assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AreEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ActualString3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CretedString3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parameter is reversed order, it's not right and For sure I will get a review comment to change this.&lt;/p&gt;

&lt;p&gt;To swap this parameter we can use find and replace with the regular expression.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Regular Expression in Visual Studio is bit different.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Add this as Search Term&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\((".*"),([^\)]*)  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Add this as Replace Term&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;($2, $1  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How its works
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fvrnithinkumar.github.io%2F2017%2F08%2F19%2Fvs-regex%2FRegEx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fvrnithinkumar.github.io%2F2017%2F08%2F19%2Fvs-regex%2FRegEx.png" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For information about regular expressions that are used in replacement patterns, see &lt;a href="https://msdn.microsoft.com/en-us/library/ewy2t5e0.aspx" rel="noopener noreferrer"&gt;Substitutions in Regular Expressions&lt;/a&gt;. To use a numbered capture group, the syntax is $1 to specify the numbered group and (x) to specify the group in question. For example, the grouped regular expression (\d)([a-z]) finds four matches in the following string: 1a 2b 3c 4d. The replacement string z$1 converts that string to z1 z2 z3 z4.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Screenshots&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Before&lt;/em&gt; :&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fvrnithinkumar.github.io%2F2017%2F08%2F19%2Fvs-regex%2Fbefore.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fvrnithinkumar.github.io%2F2017%2F08%2F19%2Fvs-regex%2Fbefore.png" alt="alt text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;After&lt;/em&gt; :&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fvrnithinkumar.github.io%2F2017%2F08%2F19%2Fvs-regex%2Fafter.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fvrnithinkumar.github.io%2F2017%2F08%2F19%2Fvs-regex%2Fafter.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Be careful to select code part you want to swap parameter. Don't apply for whole Document or Solution, It might do some harmfull effects.&lt;/li&gt;
&lt;li&gt;You can tweak the regex for other use cases where parameter pattern is different.&lt;/li&gt;
&lt;li&gt;There exist some shortcuts to reorder the parameter in VS but it didn't work for me and even if it work, We need to select each AreEqual method and apply those shortcut.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;More Reference:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://msdn.microsoft.com/en-us/library/ms243413.aspx" rel="noopener noreferrer"&gt;Assert.AreEqual Method&lt;/a&gt;&lt;br&gt;
&lt;a href="https://msdn.microsoft.com/en-us/library/2k3te2cs.aspx" rel="noopener noreferrer"&gt;Using Regular Expressions in Visual Studio&lt;/a&gt;&lt;br&gt;
&lt;a href="http://stackoverflow.com/questions/3292292/is-there-a-shortcut-to-swap-reorder-parameters-in-visual-studio-ide" rel="noopener noreferrer"&gt;Is there a shortcut to swap/reorder parameters in visual studio IDE? - Stack Overflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>visualstudio</category>
    </item>
    <item>
      <title>Hi, I'm Nithin V Rajendrakumar</title>
      <dc:creator>Nithin V Rajendrakumar</dc:creator>
      <pubDate>Sun, 25 Jun 2017 07:23:35 +0000</pubDate>
      <link>https://dev.to/vr_nithin/hi-im-nithin-v-rajendrakumar</link>
      <guid>https://dev.to/vr_nithin/hi-im-nithin-v-rajendrakumar</guid>
      <description>&lt;p&gt;I have been coding for 7 years.&lt;/p&gt;

&lt;p&gt;You can find me on Twitter as &lt;a href="https://twitter.com/VR_nithin" rel="noopener noreferrer"&gt;@VR_nithin&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Bangalore.&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: C# and C++.&lt;/p&gt;

&lt;p&gt;I am currently learning more about F#.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
