False positive error in VB?

i have following code in my VB project:

2011-07-12 11h14_29.png
The project will be compiled with no errors. I haven't found an entry in the inspection severity dialog  where i can adjust this. Is it really a narrowing conversion when i convert a DateTime to a string?

Regards
Klaus

P.S.: I'm working with Visual Studio 2008 and R# 6

3 comments

The project will compile without errors, but it won't do what you think.

The date will be converted to a string using the default format, which depends on the user's regional settings. This string will most likely contain no format placeholders, so when you pass it as the first parameter to String.Format, it won't be changed.

Try using either: String.Format("{0:dd.mm.yyyy}", Date.FromOADate(COptimierung.mrAufleseZeitpunkt))
or: Date.FromOADate(COptimierung.mrAufleseZeitpunkt).ToString("dd.mm.yyyy")

NB: You don't need the CDate(...) around the Date.FromOADate(...); the value returned from FromOADate is already a date.

0

after inspecting the code in deep i must say you are right. The code wasn't written by me (because i would have used the .ToString() methode). The code was converted from VB 6 via the Upgrade Wizard. I think the code was generated by the wizard.

Nevertheless as the code works fine for the users of the application i'm missing an option to adjust the severity of the message.

Regards
Klaus

0

Hello Klaus,

I'm afraid ReSharper detects this as an error and there's no way to suppress
errors (via comment or severity setting) at the moment. I've filed a bug-report:
http://youtrack.jetbrains.net/issue/RSRP-273926 and you're welcome to vote
for it. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

after inspecting the code in deep i must say you are right. The code
wasn't written by me (because i would have used the .ToString()
methode). The code was converted from VB 6 via the Upgrade Wizard. I
think the code was generated by the wizard.

Nevertheless as the code works fine for the users of the application
i'm missing an option to adjust the severity of the message.

Regards
Klaus
---
Original message URL:
http://devnet.jetbrains.net/message/5310023#5310023



0

Please sign in to leave a comment.