Skip to content

Commit

Permalink
Merge pull request #3855 from microsoft/tomlm/fixWaterfallDcParent
Browse files Browse the repository at this point in the history
Fix WaterfallStepContext to use parent dc properly
  • Loading branch information
Tom Laird-McConnell committed May 2, 2020
2 parents 4112072 + 27f7c48 commit a4e3b3e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
23 changes: 18 additions & 5 deletions libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ public ComponentDialog AddDialog(Dialog dialog)

public override DialogContext CreateChildContext(DialogContext dc)
{
var childDc = this.CreateInnerDc(dc.Context, dc.ActiveDialog);
childDc.Parent = dc;
return childDc;
return this.CreateInnerDc(dc, dc.ActiveDialog);
}

protected async Task EnsureInitializedAsync(DialogContext outerDc)
Expand Down Expand Up @@ -380,7 +378,22 @@ protected virtual Task<DialogTurnResult> EndComponentAsync(DialogContext outerDc
return outerDc.EndDialogAsync(result, cancellationToken);
}

private DialogContext CreateInnerDc(ITurnContext context, DialogInstance instance)
private DialogContext CreateInnerDc(DialogContext outerDc, DialogInstance instance)
{
var state = BuildDialogState(instance);

return new DialogContext(this.Dialogs, outerDc, state);
}

// NOTE: You should only call this if you don't have a dc to work with (such as OnResume())
private DialogContext CreateInnerDc(ITurnContext turnContext, DialogInstance instance)
{
var state = BuildDialogState(instance);

return new DialogContext(this.Dialogs, turnContext, state);
}

private DialogState BuildDialogState(DialogInstance instance)
{
DialogState state;

Expand All @@ -399,7 +412,7 @@ private DialogContext CreateInnerDc(ITurnContext context, DialogInstance instanc
state.DialogStack = new List<DialogInstance>();
}

return new DialogContext(this.Dialogs, context, state);
return state;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ internal WaterfallStepContext(
object result = null)
: base(
dc.Dialogs,
turnContext: dc.Context,
parentDialogContext: dc,
state: new DialogState(dc.Stack))
{
_parentWaterfall = parentWaterfall;
_nextCalled = false;
Parent = dc.Parent;
Index = index;
Options = options;
Reason = reason;
Expand Down

0 comments on commit a4e3b3e

Please sign in to comment.