Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

IDynamicMetaObjectProvider.GetMetaObject is not always called

$
0
0

I have a weird behavior of class that implements IDynamicMetaObjectProvider interface. I posted complete code for the class that causes a problem at StackOverflow:

http://stackoverflow.com/questions/20745780/idynamicmetaobjectprovider-getmetaobject-is-not-always-called

As you can see, a very simple implementation of IDynamicMetaObjectProvider results in a situation when GetMetaObject is not always called on an attempt to bind a dynamic property. The failure it not random: I see the pattern and can reproduce the failure in the following test:

[Test]publicvoidTest(){var dict =new[]{newDictionary<string,object>(){{"StringProperty","a"},{"IntProperty",1}},newDictionary<string,object>(){{"StringProperty","b"},{"IntProperty",2}},};var values =(dict.Select(x =>newDynamicDataEntry(x))asIEnumerable<dynamic>).ToArray();for(int index =0; index < values.Count(); index++){// GetMetaObject is called only first time for the line below, so it is "a" for both iterations! WHY?!!var s = values[index].StringProperty;switch(index){case0:Assert.AreEqual("a", values[index].StringProperty);Assert.AreEqual("a", s);break;case1:Assert.AreEqual("b", values[index].StringProperty);Assert.AreEqual("b", s);break;}}}

Any ideas what might cause such weird behavior?

Thanks in advance.

Vagif Abilov


Vagif Abilov


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>