Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the IDisposable local enumerator haven't properly disposed after enumerating #19

Open
quabug opened this issue Dec 5, 2024 · 0 comments

Comments

@quabug
Copy link

quabug commented Dec 5, 2024

expect to call Dispose on local enumerator in a try-finally block, like below

        public bool Any(Func<global::Foo, bool> predicate)
        {
            var copy = this;
            global::System.Collections.Generic.IEnumerator<global::Foo> enumerator_sn0QN1 = default;
            enumerator_sn0QN1 = copy.source_sn0QN1.GetEnumerator();
            try
            {
                while (enumerator_sn0QN1.MoveNext())
                {
                    var current_sn0QN1 = enumerator_sn0QN1.Current;
                    if (predicate.Invoke(current_sn0QN1))
                        return true;
                }

                return false;
            }
            finally
            {
                enumerator_sn0QN1.Dispose();
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant