Q:

Should this list initializer behavior be reported as bug in the Visual Studio C# Compiler?

First of all I will say that I've changed my design and no longer need that but getting a good answer for that will still be nice
I have the following class, ListContainer, in my code (The attached codes are all mcve):
class ListContainer
{
    public object ContainedList
    {
        get; private set;
    }

    public int Value
    {
        get; private set;
    }

    public ListContainer(object list, int value)
    {
        ContainedList = list;
        Value = value;
    }
}

And in some other class in my code I have a List<ListContainer> and I need each ListContainer to contain this List<ListContainer>, so I can implement it like that:
//Field in the class
List<ListContainer> mContainers = null;

//In the constructor:
mContainers = new List<ListContainer>();
mContainers.Add(new ListContainer(mContainers, SOME_CONST));
mContainers.Add(new ListContainer(mContainers, SOME_OTHER_CONST));

Than it works fine, but when I've tried to use list initializer:
//Field in the class
List<ListContainer> mContainers = null;

//In the constructor:
mContainers = new List<ListContainer>
{
    new ListContainer(mContainers, SOME_CONST),
    new ListContainer(mContainers, SOME_OTHER_CONST)
}

You would expect the results to be equivalent but in reality the result looks like that:
mContainers
    [0] - ListContainer
              ContainedList = null
              Value = SOME_CONST
    [1] - ListContainer
              ContainedList = null
              Value = SOME_OTHER_CONST

Seeing this results I've inspected the output MSIL of this C# compilation and seen the following code:

Now, this explains why the problem occurs, and I've even checked out in the CSharp Language Specification document and this is the defined behavior:

A List can be created and initialized as follows:
var contacts = new List<Contact> {
    new Contact {
        Name = "Chris Smith",
        PhoneNumbers = { "206-555-0101", "425-882-8080" }
    },
    new Contact {
        Name = "Bob Harris",
        PhoneNumbers = { "650-555-0199" }
    }
};

which has the same effect as
var __clist = new List<Contact>();
Contact __c1 = new Contact();
__c1.Name = "Chris Smith";
__c1.PhoneNumbers.Add("206-555-0101");
__c1.PhoneNumbers.Add("425-882-8080");
__clist.Add(__c1);
Contact __c2 = new Contact();
__c2.Name = "Bob Harris";
__c2.PhoneNumbers.Add("650-555-0199");
__clist.Add(__c2);
var contacts = __clist;

where __clist, __c1 and __c2 are temporary variables that are otherwise invisible and inaccessible.

So obviously this behaviour is intended. Is there a good reason everything is done on the temporary variable and not on the original one? since it seems like a wrong behaviour to me.

A:

The reason is to avoid race conditions with concurrent threads accessing the original variable where you would add your elements. An inconsistency would appear if a thread accesses the variable while not all elements are added to it yet.
Two threads accessing the same variable would therefore get an inconsistent list, with different elements in it.
This would not come as a shock if the elements are added on different lines, but since you use an object initializer, it is normal to perceive the object as directly initialized with all its elements in it, hence the need of a temporary, invisible, variable.

