Skip to content

Conversation

@chon219
Copy link
Member

@chon219 chon219 commented Mar 4, 2021

Fixes #3356

Description

OnCondition.getExpression() was caches the root expression, but all of the children which override getExpression() were not. This means all child conditions which overrode getExpression() were calling Expression.parse() on EVERY call.

Specific Changes

  • Changed getExpression() documentation to state that it must return CACHED expression
  • Moved all of the creation logic to protected method createExpression(). This should be backward compatible with classes which do override this method but creates a pattern that causes correct behavior for all OnCondition classes written in the future.
  • Changed all of our OnCondition classes from public getExpression() => protected createExpression()

Testing

@chon219 chon219 added the Area: Adaptive The issue is related to Adaptive dialogs label Mar 4, 2021
@chon219 chon219 requested a review from joshgummersall March 4, 2021 07:45
@chon219 chon219 requested review from a team as code owners March 4, 2021 07:45
@chon219 chon219 requested a review from Stevenic March 4, 2021 07:45
@coveralls
Copy link

coveralls commented Mar 4, 2021

Pull Request Test Coverage Report for Build 620406469

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 201 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.2%) to 84.923%

Files with Coverage Reduction New Missed Lines %
libraries/botbuilder-dialogs-adaptive/src/selectors/trueSelector.ts 1 90.48%
libraries/botbuilder-dialogs-adaptive/src/conditions/onCondition.ts 7 87.5%
libraries/botbuilder-dialogs-adaptive/src/adaptiveDialog.ts 193 38.17%
Totals Coverage Status
Change from base Build 614831139: 0.2%
Covered Lines: 18636
Relevant Lines: 20913

💛 - Coveralls

Copy link
Contributor

@joshgummersall joshgummersall left a comment

Choose a reason for hiding this comment

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

All looks good to me. Was this an issue found during Composer testing?

}

return Expression.andExpression.apply(Expression, expressions);
return Expression.andExpression(...expressions);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@chon219
Copy link
Member Author

chon219 commented Mar 5, 2021

All looks good to me. Was this an issue found during Composer testing?

No, I was porting #3320 and found that we have not ported the latest getExpression/createExpression changes from C#.

@chon219 chon219 merged commit f8d0ae3 into main Mar 5, 2021
@chon219 chon219 deleted the zim/trigger-condition-expression branch March 5, 2021 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Adaptive The issue is related to Adaptive dialogs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

port: OnCondition is not correctly caching expressions causing constant Expression.parse calls

4 participants