"Return value of pure method is not used"

I realize the value of this warning so I don't want to turn it off, but I have a common pattern in my code that causes this warning to show up a lot when using a DbDataReader to read results from a database I get:

byte[] data = new byte[reader.GetBytes(0, 0, null, 0, 0)];
reader.GetBytes(0, 0, data, 0, data.Length);  // this line gives me the warning since I'm ignoring the return value

Am I doing something wrong here?  It seems like ReSharper shouldn't produce this warning for calls that have array parameters (or other non primitive types).

4 comments

Hello,

Could you please attach a screenshot demonstrating this warning? I'm afraid
I wasn't able to reproduce this behavior. Thank you!

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

I realize the value of this warning so I don't want to turn it off,
but I have a common pattern in my code that causes this warning to
show up a lot when using a DbDataReader to read results from a
database I get:

byte[] data = new byte[reader.GetBytes(0, 0, null, 0, 0)];

reader.GetBytes(0, 0, data, 0, data.Length);  // this line gives me
the warning since I'm ignoring the return value

Am I doing something wrong here?  It seems like ReSharper shouldn't
produce this warning for calls that have array parameters (or other
non primitive types).

---
Original message URL:
http://devnet.jetbrains.net/message/5309270#5309270



0

puremethod.png
I saw this issue to so I thought I would add an image.

*Edit I do realize this is a valid error and when I remove "FirstOrDefault" the error goes away.

0

Sorry for the late response.  Here is a screenshot of the issue:
invalidpuremethodwarning.png
Because the method modifies the contents of the data array it is still useful to call without examining the return value.

0

I'm still seeing this in ReSharper 6.1 EAP.  I would love to be able to get my solution to full green status by fixing these erroneous warnings.

0

Please sign in to leave a comment.