The following code returns a false positive, which caused my boss to yell at me for writing sloppy code (and I didn't even write this, it's from Stack Overflow)..
public static class BatchLinq
public static IEnumerable<IEnumerable<T>> Batch<T>(this IEnumerable<T> source, int size)
if (size <= 0)
throw new ArgumentOutOfRangeException("size", "Must be greater than zero.");
using (var enumerator = source.GetEnumerator())
int i = 0;
// Batch is a local function closing over `i` and `enumerator` that
// executes the inner batch enumeration
do yield return enumerator.Current; // Access to disposed closure
while (++i < size && enumerator.MoveNext()); // Access to disposed closure
yield return Batch();
while (++i < size && enumerator.MoveNext()); // discard skipped items
Related: https://resharper-support.jetbrains.com/hc/en-us/community/posts/206661285-Still-confused-about-Access-to-modified-closure-?input_string=%22Access%20to%20displosed%20closur - which discusses that JetBrains added three annotations to help with this. HOWEVER, this is buried and not searchable via Google when I type "Access to disposed closure" in the search engine, I see nothing about these attributes. Likewise, the ToolTip in Visual Studio 2017 says nothing about these annotaitons, either.
Past instances of false positives: