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

[PORT] fix index access bug caused by Access Modifiers of C# class #1918

Closed
tomlm opened this issue Mar 18, 2020 · 0 comments · Fixed by #1919
Closed

[PORT] fix index access bug caused by Access Modifiers of C# class #1918

tomlm opened this issue Mar 18, 2020 · 0 comments · Fixed by #1919
Labels
R9 Release 9 - May 15th, 2020
Milestone

Comments

@tomlm
Copy link
Contributor

tomlm commented Mar 18, 2020

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]

@github-actions github-actions bot added lg R9 Release 9 - May 15th, 2020 labels Mar 18, 2020
@munozemilio munozemilio added this to the R9 milestone Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R9 Release 9 - May 15th, 2020
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants