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

Problem with Barrel instance in the case of using System.Linq.Select #105

Open
Senso4sLab opened this issue Oct 13, 2021 · 0 comments
Open

Comments

@Senso4sLab
Copy link

Here is a simplified code of my problem. The problem is that the debugger skips the last line of code which is
[var _barrelResult = keys.Select(key => _barrel.Get<string>(key));]. If I use foreach loop everything works just fine. I assume that the Select method causes some problem because of an instance of _barrel. Is it possible to get some deeper explanation why this happen? It is very interesting that I do not get any exceptions. Please note this is a simplified example, in general, this code can not be applied in the constructor.

public class ViewModelGeneral: BaseViewModel
    {

        private readonly IBarrel _barrel = null;
        public ViewModelGeneral(IBarrel barrel)
        {
            _barrel = barrel;

            IList<string> keys = new List<string>();          
            
            // this approach works just fine
            List<string> resultsList = new List<string>();
            foreach(var key in keys)
            {
                var result = _barrel.Get<string>(key);
                resultsList.Add(result);
            }
           // this approach does not work, the debugger skips this line of code
            var _barrelResult = keys.Select(key => _barrel.Get<string>(key));

        }
    }
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