Improve Redundant Cast inspection in VB

I have found following piece of code in a VB application i have to maintain:

dim monthValue as string
monthValue = CDate(dtpDateTimePicker.Value).Month.ToString("00")

The value of a DateTimepicker is already a date, so the CDate() conversion is redundant. I tried to create a custom pattern to find this kind of code, but nevertheless how i define the variables i got no or wrong results. I think it should be no problem for R# to generate a warning on this type of casts (also for the other C... like CInt(), CStr() and so on).

So i ask the Jetbrains team if they could enhance the Redundant Cast inspection to recognize this special VB cast functions.


1 comment
Andrey Serebryansky
Comment actions Permalink

Hello Klaus
     Thank you for suggestion! You're welcome to vote for the following feature request:

Andrey Serebryansky

Software Developer

JetBrains, Inc

"Develop with pleasure!"


Please sign in to leave a comment.