I’m coming up to speed with Gendarme, the open source assembly inspector.
Mostly, the tool seems to deliver on its promise, but I’m having a problem with a false positive.
The EnsureLocalDisposalRule rule is intended to flag situations where Disposable instances aren’t properly cleaned up.
Sounds great - except the rule is triggering on code where I don’t (can’t?) see anything to fix …
Check out this example:
I’ve thought that the foreach statement automatically disposed of the enumeration when iteration completed.
In fact, the MSDN page “Using foreach with Collections” says:
The foreach statement provides support for disposable enumerators. If an enumerator implements the IDisposable interface, the foreach statement guarantees that the Dispose method is called on the enumerator no matter how the enumeration loop is terminated.
So, surely this Gendarme rule is a false positive?