New CodeRush Community Plugin - DX_ConvertToTryParse

DX_ConvertToTryParse

This new plugin provides a new item for the Code menu which converts…

ConvertToTryParseBefore_thumb[5]

…into…

ConvertToTryParseAfter_thumb[2]

There is a small limitation in this version. The new variable introduced (“Success”) is currently hardcoded and may clash with an existing variable. I’ll fix that in an update. I just wanted to get this out there for now.

Download DX_ConvertToTryParse

10 comment(s)
Miha Markic - DevExpress MVP
Miha Markic - DevExpress MVP

Well, actually it does change the behavior. In original case you'll get an exception when an input text doesn't represent a number while in "refactored" case there won't be an exception.

The addition of code is insignificant as long as behavior is the same.

3 March, 2011
Nate Laff
Nate Laff

Nice one! This should be included as an out of the box refactoring.

3 March, 2011
Rory Becker - DevExpress
Rory Becker - DevExpress

@Miha Fair enough... I'll sort that out ASAP :)

3 March, 2011
SimonMartin
SimonMartin

Does this work for VB.NET?

I couldn't seem to get it...

4 March, 2011
Rory Becker - DevExpress
Rory Becker - DevExpress

@Miha Latest version is reconfigured as a CodeProvider rather than a Refactoring. :)

@SimonMartin Yes this should work with VB.Net

Place your caret on the = sign of...

       Dim X As Integer = Integer.Parse("34")

...and hit your CodeRush Refactor key.

It is possible that the .dll may need to be unblocked. see code.google.com/.../InstallInstructions

4 March, 2011
Mark Miller (DevExpress)
Mark Miller (DevExpress)

Rory, I think this should be available when the caret is on the Parse method call.

8 March, 2011
Rory Becker - DevExpress
Rory Becker - DevExpress

Seems pretty reasonable. I'll see what I can do. :)

8 March, 2011
Rory Becker - DevExpress
Rory Becker - DevExpress

Ok that's sorted  :) Latest build (1719) has that covered.

10 March, 2011
Richard Slater (Makemedia)
Richard Slater (Makemedia)

Thanks, I can not overstate how much time this one plugin has saved me.

14 March, 2011
Rory Becker - DevExpress
Rory Becker - DevExpress

@Richard That's great to hear Richard.

We always like to hear of people becoming more productive through the use of our tools :)

14 March, 2011

Please login or register to post comments.