arklumpus / MuPDFCore

Multiplatform .NET bindings for MuPDF
GNU Affero General Public License v3.0
115 stars 20 forks source link

MuPDFPageCollection.GetEnumerator bug #4

Closed thinker1990 closed 3 years ago

thinker1990 commented 3 years ago

Hi, there is a bug in MuPDFPageCollection.GetEnumerator implemention.

        public IEnumerator<MuPDFPage> GetEnumerator()
        {
            for (int i = 0; i < Pages.Length; i++)
            {
                if (Pages[i] == null)
                {
                    Pages[i] = new MuPDFPage(OwnerContext, OwnerDocument, i);
                }
            }

            return (IEnumerator<MuPDFPage>)Pages.GetEnumerator();
        }

The type of Pages.GetEnumerator() is SZArrayEnumerator, it can not be cast to System.Collections.Generic.IEnumerator.

Invalid cast

arklumpus commented 3 years ago

Thank you for spotting this! I have included your fix in version 1.2.4 (the NuGet package should become available as soon as it finishes validation and indexing).