Skip to content

Added support of accessing index of dynamic object#142

Merged
davideicardi merged 4 commits into
dynamicexpresso:masterfrom
tingwei628:master
May 21, 2021
Merged

Added support of accessing index of dynamic object#142
davideicardi merged 4 commits into
dynamicexpresso:masterfrom
tingwei628:master

Conversation

@tingwei628

Copy link
Copy Markdown
Contributor

Fixes #127, #92
Thanks !

@davideicardi davideicardi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

Just added some minor comments.

Assert.Throws<RuntimeBinderException>(() => interpreter.Eval("dyn.BAR", new Parameter("dyn", dyn)));
}

[Test]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some minor code alignment problems here and in other files? Probably due to tab/space mismatch ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i will format codes again.

@tingwei628 tingwei628 May 21, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix 5e133f3

var interpreter = new Interpreter().SetVariable("dyn", (object)dyn);
Assert.AreEqual(dyn.Sub[0], interpreter.Eval("dyn.Sub[0]"));
}

@davideicardi davideicardi May 20, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to try some invalid cases?
Here some suggestions that I would expect should generate a parse exception:

  • try to use index for a property that is not an array
  • try to use as an index an invalid type (like passing a string?)
  • try to pass some invalid syntax like dyn.Sub[0, dyn.Sub 0] or dyn.Sub[[0]]
  • try to get an out of bound element (this just to check that exception are handled correctly ... )

What do you think?

@tingwei628 tingwei628 May 20, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add more cases like what you said. Thanks !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix cfe6d99

@davideicardi

Copy link
Copy Markdown
Member

It would be very nice that you could also add a note in the README regarding this new dynamic feature (currently there isn't a specific section for dynamic, it is only mentioned in Features and Limitations. Maybe you can just review that phrases or add a specific section, as you prefer).

@tingwei628

tingwei628 commented May 20, 2021

Copy link
Copy Markdown
Contributor Author

It would be very nice that you could also add a note in the README regarding this new dynamic feature (currently there isn't a specific section for dynamic, it is only mentioned in Features and Limitations. Maybe you can just review that phrases or add a specific section, as you prefer).

I would add some notes to Limitations and Feature in README.

@tingwei628

Copy link
Copy Markdown
Contributor Author

Done! Thanks!

@davideicardi davideicardi merged commit 549cb83 into dynamicexpresso:master May 21, 2021
@davideicardi

Copy link
Copy Markdown
Member

Thank you! Merged!

@davideicardi

Copy link
Copy Markdown
Member

Release v2.5.0 with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamicObject w/ index access throws ParseException

2 participants