c# - EnsureLocalDisposalRule for XmlNodeList -
when run gendarme 2.11 on c#.net project following code triggers ensurelocaldisposalrule:
xmldocument myxmldoc = this.getxmldoc(); foreach (xmlnode mynode in myxmldoc.getelementsbytagname("tagname")) { ... mynode ... }
with message:
local of type 'xmlnodelist' not disposed of (at least not locally).
after reading rule description attempted rewrite follows:
xmldocument myxmldoc = this.getxmldoc(); using (xmlnodelist mynodelist = myxmldoc.getelementsbytagname("tagname")) { foreach (xmlnode mynode in mynodelist ) { ... mynode ... } }
but gives error:
'system.xml.xmlnodelist': type used in using statement must implicitly convertible 'system.idisposable'
what causing this? bug in gendarme? or have misunderstood rule? how code improved?
Comments
Post a Comment