Closed
Description
Port this change from botbuilder-dotnet/master branch:
microsoft/botbuilder-dotnet#3554
Close: #3555
Bug description: Assume there is a static class PublicA
, and it contains a private class A
, the structure shown as below:
public static class PublicA
{
public static object GetList()
{
return new List<A> { new A("hi") };
}
private class A
{
public A(string name)
{
this.Name = name;
}
public string Name { get; set; }
}
}
We call the static method in another class (which has no access to class A
), and use dynamic as an intermediate variable. Code as below:
var list = PublicA.GetList();
dynamic dy = list;
var result = dy[0];
When running through the code, the error occurs with the message: Cannot apply indexing with [] to an expression of type 'object'
So, the root cause of the issue is that when we cast a list value (with a specific object Generics, and the caller has no access to this class) to dynamic, some features of List
would be lost.
Changed projects
- AdaptiveExpressions
- AdaptiveExpressions.Tests
[LG,R9]