When I run the attached Program.cs as a console app, I get this output:
```
iris rows: 150
iris50 rows: 50
species length: 150
species50 length: 150
iris50["Species"].Length: 50
```
I expected species50 to have length 50. It looks like the first iris object used at the dynamic call site is getting cached and reused for subsequent calls.
Comments: It seems to be a bug or intended behavior in the DLR, not an R.NET bug. As mentioned in the previous comment, the function GetMetaObject is not called by the DLR on the second call to GetSpecies. The following code however retrieves the right length. I'll consider posting a stackoverflow question if no prior info on this topic. ``` C# dynamic iris = engine.Evaluate("iris").AsDataFrame(); dynamic iris50 = engine.Evaluate("iris[1:50,]").AsDataFrame(); Assert.AreEqual(150, iris.RowCount); Assert.AreEqual(50, iris50.RowCount); var species50 = (DynamicVector)iris50.Species; var species = (DynamicVector)iris.Species; Assert.AreEqual(150, species.Length); Assert.AreEqual(50, species50.Length); Assert.AreEqual(iris50["Species"].Length, 50); ```
```
iris rows: 150
iris50 rows: 50
species length: 150
species50 length: 150
iris50["Species"].Length: 50
```
I expected species50 to have length 50. It looks like the first iris object used at the dynamic call site is getting cached and reused for subsequent calls.
Comments: It seems to be a bug or intended behavior in the DLR, not an R.NET bug. As mentioned in the previous comment, the function GetMetaObject is not called by the DLR on the second call to GetSpecies. The following code however retrieves the right length. I'll consider posting a stackoverflow question if no prior info on this topic. ``` C# dynamic iris = engine.Evaluate("iris").AsDataFrame(); dynamic iris50 = engine.Evaluate("iris[1:50,]").AsDataFrame(); Assert.AreEqual(150, iris.RowCount); Assert.AreEqual(50, iris50.RowCount); var species50 = (DynamicVector)iris50.Species; var species = (DynamicVector)iris.Species; Assert.AreEqual(150, species.Length); Assert.AreEqual(50, species50.Length); Assert.AreEqual(iris50["Species"].Length, 50); ```