Identifying data readers that have not been closed

2 posts, 0 answers
  1. vatrivedi
    vatrivedi avatar
    2 posts
    Member since:
    Sep 2014

    Posted 29 Sep 2014 Link to this post


    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?


  2. Svetlozar
    Svetlozar avatar
    260 posts

    Posted 02 Oct 2014 Link to this post


    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.


    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top