A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/MapsterMapper/Mapster/issues/272 below:

IEnumerable is enumerating twice when adapted to array · Issue #272 · MapsterMapper/Mapster · GitHub

When adapting IEnumerable to an array, it's adapted twice.

Example of code:

        static void Main(string[] args)
        {
            GetMyObjects().Adapt<MyObject[]>();

            Console.WriteLine(EnumerateTimes);
        }

        static IEnumerable<MyObject> GetMyObjects()
        {
            EnumerateTimes++;
            yield return new MyObject { SomeProperty = "A" };
            yield return new MyObject { SomeProperty = "B" };
        }

        static int EnumerateTimes = 0;

Result of executing: 2.
Expected result: 1.

Version: 6.5.0.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4