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] [DCR] Normalize all expression and add '=' to force expression. #1592

Closed
tomlm opened this issue Jan 18, 2020 · 1 comment
Closed
Assignees

Comments

@tomlm
Copy link
Contributor

tomlm commented Jan 18, 2020

Port this change from botbuilder-dotnet/master branch:
microsoft/botbuilder-dotnet#3253

  • Added StringExpression,ValueExpression, etc. for expression or value access
  • added a ton of unit tests for the expression stuff
  • For ambigious expressions (StringExpression and ValueExpression) it will treat as string interpolation unless it starts with =. "Hello @{world}" ==> "hello world", "=user.foo" => Expression("user.foo")
  • Added assignment operators so you can assign string expressions to expression properties.
  • cleaned up dialogs files
  • Exposed Dialogset to DialogManager so you can register external external dialogs
  • Added DialogId to BeginDialog to allow you to invoke external dialogs

It basically boils down to how to deal with strings as input:

  • StringExpression always assumes string interpolation unless prefixed with =, producing a string
  • ValueExpression always assumes string interpolation unless prefixed with =, producing an object which MAY be a string
  • ExpressionProperty<T> always assumes strings represent something to be interpreted as the type of T, so always producing object of T.

StringExpression

Interpretation of string is as a string interpolation result unless =.

| Input                         | Result        |
|-------------------------------|---------------|
| "13"                          | "13"          |
| "=13"                         | "13"          |
| "user.age"                    | "user.age"    |
| "=user.age"                   | "13"          |
| "Hello world"                 | "Hello World" |
| "='Hello world'"              | "Hello World" |
| "Hello @{user.name}"          | "Hello Joe"   |
| "=concat('Hello ', user.name) | "Hello Joe"   |

BoolExpression

Interpretation of string is as a bool expression

| Input           | Result        |
|-----------------|---------------|
| true            | true          |
| "true"          | true          |
| "=true"         | true          |
| "user.age > 3"  | true          |
| "=user.age > 3" | true          |
| "bad"           | default(bool) |
| "bad @{bad}"    | default(bool) |

IntExpression

Interpretation of string is as a int expression

| Input                | Result       |
|----------------------|--------------|
| 13                   | 13           |
| "13"                 | 13           |
| "=13"                | 13           |
| "x.y.z"              | 13           |
| "=x.y.z"             | 13           |
| "Hello world"        | default(int) |
| "Hello @{user.name}" | default(int) |

FloatExpression

Interpretation of string is as a float expression

| Input        | Result         |
|--------------|----------------|
| 3.14F        | 3.14           |
| "3.14"       | 3.14           |
| "=3.14"      | 3.14           |
| "x.y.z"      | 3.14           |
| "=x.y.z"     | 3.14           |
| "bad"        | default(float) |
| "bad @{bad}" | default(float) |

ExpressionProperty

Interpretation of string is as a T expression

| Input        | Result     |
|--------------|------------|
| T            | T          |
| "x.y.z"      | T          |
| "=x.y.z"     | T          |
| "bad"        | default(T) |
| "bad @{bad}" | default(T) |

ValueExpression (T == object)

Interpretation of string is as a string interpolation result unless =.

| Input                         | Result      |
|-------------------------------|-------------|
| object                        | object      |
| "13"                          | "13"        |
| "=13"                         | 13          |
| "x.y.z"                       | "x.y.z"     |
| "=x.y.z"                      | object      |
| "='x.y.z'"                    | "x.y.z"     |
| "Hello @{user.name}"          | "Hello Joe" |
| "=concat('Hello ', user.name) | "Hello Joe" |

Also Fixes Bugs
#3166 Luis settings not parsed correctly
#3236 Use dialogId as an expression
#3219 HttpRequest body not parsed correctly

@Stevenic Stevenic self-assigned this Jan 29, 2020
@luhan2017
Copy link
Contributor

resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants