From 0173a8b76a69c819b91c2d03bc81be2d572d9508 Mon Sep 17 00:00:00 2001 From: stevengum <14935595+stevengum@users.noreply.github.com> Date: Wed, 6 May 2020 14:42:39 -0700 Subject: [PATCH 1/4] override OnComputeId in AdaptiveSkillDialog --- .../Skills/AdaptiveSkillDialog.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs index ebd698f40d..abc71f8a96 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using AdaptiveExpressions.Properties; +using Microsoft.Bot.Builder.Dialogs.Adaptive.Templates; using Microsoft.Bot.Builder.Skills; using Microsoft.Bot.Schema; using Newtonsoft.Json; @@ -161,5 +162,21 @@ public override Task ContinueDialogAsync(DialogContext dc, Can return base.ContinueDialogAsync(dc, cancellationToken); } + + protected override string OnComputeId() + { + var appId = string.Empty; + if (!string.IsNullOrWhiteSpace(SkillAppId?.Value)) + { + appId = SkillAppId.Value; + } + + if (Activity is ActivityTemplate at) + { + return $"Skill[{appId}:('{StringUtils.Ellipsis(at.Template.Trim(), 30)}')]"; + } + + return $"Skill[{appId}:('{StringUtils.Ellipsis(Activity?.ToString().Trim(), 30)}')]"; + } } } From ea6a5106061a88ff9b56948f68d5924308cc0475 Mon Sep 17 00:00:00 2001 From: stevengum <14935595+stevengum@users.noreply.github.com> Date: Wed, 6 May 2020 15:14:37 -0700 Subject: [PATCH 2/4] refactor AdaptiveSkillDialog.OnComputeId() --- .../Skills/AdaptiveSkillDialog.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs index abc71f8a96..79a3f47851 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs @@ -165,18 +165,19 @@ public override Task ContinueDialogAsync(DialogContext dc, Can protected override string OnComputeId() { - var appId = string.Empty; - if (!string.IsNullOrWhiteSpace(SkillAppId?.Value)) - { - appId = SkillAppId.Value; - } + var appId = SkillAppId?.ToString() ?? string.Empty; + string activity; if (Activity is ActivityTemplate at) { - return $"Skill[{appId}:('{StringUtils.Ellipsis(at.Template.Trim(), 30)}')]"; + activity = StringUtils.Ellipsis(at.Template.Trim(), 30); + } + else + { + activity = StringUtils.Ellipsis(Activity?.ToString().Trim(), 30); } - return $"Skill[{appId}:('{StringUtils.Ellipsis(Activity?.ToString().Trim(), 30)}')]"; + return $"{this.GetType().Name}[Skill('{appId}'),('{activity}')]"; } } } From cfdcb20852267908e97bd3060120706f37cd534e Mon Sep 17 00:00:00 2001 From: stevengum <14935595+stevengum@users.noreply.github.com> Date: Wed, 6 May 2020 15:53:34 -0700 Subject: [PATCH 3/4] remove superfluous parenthesis around activity --- .../Skills/AdaptiveSkillDialog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs index 79a3f47851..18a1831c26 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs @@ -177,7 +177,7 @@ protected override string OnComputeId() activity = StringUtils.Ellipsis(Activity?.ToString().Trim(), 30); } - return $"{this.GetType().Name}[Skill('{appId}'),('{activity}')]"; + return $"{this.GetType().Name}[Skill('{appId}'),'{activity}']"; } } } From e68f0339385e0d02f561bf2f84d6d32b4e593e9a Mon Sep 17 00:00:00 2001 From: stevengum <14935595+stevengum@users.noreply.github.com> Date: Wed, 6 May 2020 21:33:36 -0700 Subject: [PATCH 4/4] apply @stevenic's PR feedback --- .../Skills/AdaptiveSkillDialog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs index 18a1831c26..cc390012ca 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Skills/AdaptiveSkillDialog.cs @@ -177,7 +177,7 @@ protected override string OnComputeId() activity = StringUtils.Ellipsis(Activity?.ToString().Trim(), 30); } - return $"{this.GetType().Name}[Skill('{appId}'),'{activity}']"; + return $"{this.GetType().Name}['{appId}','{activity}']"; } } }