This is a migrated thread and some comments may be shown as answers.

Identifying data readers that have not been closed

1 Answer 24 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
vatrivedi
Top achievements
Rank 1
vatrivedi asked on 29 Sep 2014, 02:05 PM
Hi, 

We have lots of code using data readers as follows:

Dim reader As IDataReader = Db1.ExecuteReader(objCommand)


Is there any option in JustCode to identify if we have really closed the data readers using the following code?

reader.Close()

1 Answer, 1 is accepted

Sort by
0
Svetlozar
Telerik team
answered on 02 Oct 2014, 11:44 AM
Hi,

Thank you for your feedback!

One approach would be to implement a JustCode warning for that. You can have a look at our extensibility samples. Here is the Excessive Local Variables warning.We will be glad to help if you have questions. Have in mind that the case with local variables is the easy one, because you have all the usages in the same file, so it basically comes down to get all variable declarations of type Connection and fitter those who don't have corresponding Close invocations. Control-flow branches make it a little bit difficult, but it is still doable. The case with fields is a little bit trickier, because you can intentionally delay the closing in other method (or even type), so it will be hard to say this field has missing Close method.


Regards,
Svetlozar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Code Analysis
Asked by
vatrivedi
Top achievements
Rank 1
Answers by
Svetlozar
Telerik team
Share this question
or