diff --git a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Node.cs b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Node.cs index c1151c077..3ee0f34f6 100644 --- a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Node.cs +++ b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Node.cs @@ -64,7 +64,6 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees /// public TriggerTree Tree { get; } - #if TraceTree public static bool ShowTrace = true; #endif @@ -487,6 +486,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees Debug.Assert(CheckInvariants(), "bad invariants"); #endif } + return added; } @@ -531,6 +531,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees break; } } + if (add) { #if TraceTree diff --git a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Quantifier.cs b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Quantifier.cs index 79ec72e2a..fc8fe088f 100644 --- a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Quantifier.cs +++ b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Quantifier.cs @@ -18,7 +18,8 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees /// /// Create a new clause for each possible binding of variable. /// - Any }; + Any } +; /// /// Quantifier for allowing runtime expansion of expressions. @@ -56,7 +57,6 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees public override string ToString() { return $"{Type} {Variable} {Bindings.Count()}"; - } } } diff --git a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Trigger.cs b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Trigger.cs index 1c68db1b1..1c8dd48a3 100644 --- a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Trigger.cs +++ b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/Trigger.cs @@ -196,6 +196,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees soFar.Clear(); break; } + if (first) { soFar.AddRange(clauses); @@ -214,14 +215,17 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees newClauses.Add(new Clause(children)); } } + soFar = newClauses; } } + foreach (var clause in soFar) { yield return clause; } } + break; case ExpressionType.Or: { @@ -233,6 +237,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees } } } + break; case TriggerTree.Optional: { @@ -242,6 +247,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees yield return clause; } } + break; default: // True becomes empty expression and false drops clause @@ -256,6 +262,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees { yield return new Clause(expression); } + break; } } @@ -281,11 +288,13 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees break; } } + if (!found) { children.Add(pred); } } + _clauses[i] = new Clause(children); } } @@ -349,6 +358,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees { newClauses.AddRange(ExpandQuantifier(quantifier, clause)); } + _clauses = newClauses; } } @@ -375,11 +385,13 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees children.Add(SubstituteVariable(variable, binding, child, out var childChanged)); changed = changed || childChanged; } + if (changed) { newExpr = new Expression(expression.Evaluator, children.ToArray()); } } + return newExpr; } @@ -416,6 +428,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees } } } + yield return new Clause(children); } else @@ -433,10 +446,12 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees changed = changed || predicateChanged; children.Add(newPredicate); } + if (changed) { newClause.AnyBindings.Add(quantifier.Variable, binding); } + newClause.Children = children.ToArray(); yield return newClause; if (!changed) @@ -458,6 +473,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees break; } } + if (!changed) { yield return clause; @@ -488,6 +504,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees } } } + clause.Children = predicates.ToArray(); } } diff --git a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/TriggerTree.cs b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/TriggerTree.cs index 05860bd31..b291e5d12 100644 --- a/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/TriggerTree.cs +++ b/libraries/Microsoft.Bot.Builder.AI.TriggerTrees/TriggerTree.cs @@ -108,6 +108,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees { eval = BuiltInFunctions.Lookup(type); } + return eval; } @@ -233,6 +234,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees output.WriteLine(" -> {"); first = false; } + output.WriteLine($"{spaces}{NameNode(child)}"); } diff --git a/libraries/Microsoft.Bot.Builder.Azure/CosmosDbStorage.cs b/libraries/Microsoft.Bot.Builder.Azure/CosmosDbStorage.cs index 0f3b261d8..877c7dacb 100644 --- a/libraries/Microsoft.Bot.Builder.Azure/CosmosDbStorage.cs +++ b/libraries/Microsoft.Bot.Builder.Azure/CosmosDbStorage.cs @@ -35,7 +35,6 @@ namespace Microsoft.Bot.Builder.Azure private readonly IDocumentClient _client; private string _collectionLink = null; - /// /// Initializes a new instance of the class. /// using the provided CosmosDB credentials, database ID, and collection ID. diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/BaseInvokeDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/BaseInvokeDialog.cs index 263da78c6..4a9efa10b 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/BaseInvokeDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/BaseInvokeDialog.cs @@ -18,6 +18,22 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions /// Action which calls another dialog. public abstract class BaseInvokeDialog : DialogAction { + public BaseInvokeDialog(string dialogIdToCall = null, string property = null, IDictionary bindingOptions = null) + : base() + { + this.DialogId = dialogIdToCall; + + if (bindingOptions != null) + { + this.Options = bindingOptions; + } + + if (!string.IsNullOrEmpty(property)) + { + Property = property; + } + } + /// /// Gets or sets configurable options for the dialog. /// @@ -45,22 +61,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions } } - public BaseInvokeDialog(string dialogIdToCall = null, string property = null, IDictionary bindingOptions = null) - : base() - { - this.DialogId = dialogIdToCall; - - if (bindingOptions != null) - { - this.Options = bindingOptions; - } - - if (!string.IsNullOrEmpty(property)) - { - Property = property; - } - } - public override List ListDependencies() { return new List(); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/CodeAction.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/CodeAction.cs index fac02ab04..3d54d361f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/CodeAction.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/CodeAction.cs @@ -11,13 +11,14 @@ using Microsoft.Bot.Builder.Dialogs; namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions { - using CodeActionHandler = Func>; + using CodeActionHandler = System.Func>; public class CodeAction : DialogAction { private readonly CodeActionHandler codeHandler; - public CodeAction(CodeActionHandler codeHandler, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base() + public CodeAction(CodeActionHandler codeHandler, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) + : base() { this.RegisterSourceLocation(callerPath, callerLine); this.codeHandler = codeHandler ?? throw new ArgumentNullException(nameof(codeHandler)); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DebugBreak.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DebugBreak.cs index 0a4faf007..e528e2bf7 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DebugBreak.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DebugBreak.cs @@ -25,6 +25,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions { Debugger.Break(); } + return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DeleteProperty.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DeleteProperty.cs index 42ff2ae06..1f9cb887f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DeleteProperty.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/DeleteProperty.cs @@ -20,7 +20,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions public string Property { get; set; } [JsonConstructor] - public DeleteProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base() + public DeleteProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) + : base() { this.RegisterSourceLocation(callerPath, callerLine); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditActions.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditActions.cs index b41ac0fef..9da625c93 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditActions.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditActions.cs @@ -14,6 +14,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions /// public class EditActions : DialogAction, IDialogDependencies { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EditActions([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) + : base() + { + this.RegisterSourceLocation(sourceFilePath, sourceLineNumber); + } + /// /// Gets or sets the actions to be applied to the active action. /// @@ -26,19 +36,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions [JsonProperty("changeType")] public ActionChangeType ChangeType { get; set; } - /// - /// Initializes a new instance of the class. - /// - [JsonConstructor] - public EditActions([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) - : base() + public override List ListDependencies() { - this.RegisterSourceLocation(sourceFilePath, sourceLineNumber); + return this.Actions; } protected override async Task OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (dc is SequenceContext sc) { var planActions = Actions.Select(s => new ActionState() @@ -74,11 +78,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions var idList = Actions.Select(s => s.Id); return $"{nameof(EditActions)}({this.ChangeType}|{string.Join(",", idList)})"; } - - public override List ListDependencies() - { - return this.Actions; - } - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditArray.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditArray.cs index 3e643d84f..685f019bf 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditArray.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EditArray.cs @@ -21,6 +21,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions /// public class EditArray : DialogAction { + private Expression value; + private Expression arrayProperty; + private Expression resultProperty; + public enum ArrayChangeType { /// @@ -49,10 +53,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions Clear } - private Expression value; - private Expression arrayProperty; - private Expression resultProperty; - [JsonConstructor] public EditArray([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base() @@ -60,11 +60,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions this.RegisterSourceLocation(callerPath, callerLine); } - protected override string OnComputeId() - { - return $"array[{ChangeType + ": " + ArrayProperty}]"; - } - /// /// Gets or sets type of change being applied /// @@ -72,6 +67,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions [JsonProperty("changeType")] public ArrayChangeType ChangeType { get; set; } + protected override string OnComputeId() + { + return $"array[{ChangeType + ": " + ArrayProperty}]"; + } + /// /// Gets or sets memory expression of the array to manipulate. /// Edit @@ -142,7 +142,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions if (string.IsNullOrEmpty(ArrayProperty)) { - throw new Exception($"EditArray: \"{ ChangeType }\" operation couldn't be performed because the arrayProperty wasn't specified."); + throw new Exception($"EditArray: \"{ChangeType}\" operation couldn't be performed because the arrayProperty wasn't specified."); } var array = dc.State.GetValue(this.arrayProperty, new JArray()); @@ -217,6 +217,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions throw new Exception($"EditArray: \"{ChangeType}\" operation couldn't be performed for array \"{ArrayProperty}\" because a value wasn't specified."); } } - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EmitEvent.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EmitEvent.cs index a24d1973d..d1310854a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EmitEvent.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EmitEvent.cs @@ -16,9 +16,21 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions private const string eventValueProperty = "eventValue"; public string EventName { get; set; } + public object EventValue { get; set; } + public bool BubbleEvent { get; set; } + [JsonConstructor] + public EmitEvent(string eventName = null, object eventValue = null, bool bubble = true, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) + : base() + { + this.RegisterSourceLocation(callerPath, callerLine); + this.EventName = eventName; + this.EventValue = EventValue; + this.BubbleEvent = bubble; + } + public string EventValueProperty { get @@ -27,6 +39,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions { return InputBindings[eventValueProperty]; } + return string.Empty; } @@ -50,16 +63,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions // } //} - [JsonConstructor] - public EmitEvent(string eventName = null, object eventValue = null, bool bubble = true, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) - : base() - { - this.RegisterSourceLocation(callerPath, callerLine); - this.EventName = eventName; - this.EventValue = EventValue; - this.BubbleEvent = bubble; - } - protected override async Task OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) { if (options is CancellationToken) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndDialog.cs index 5519845ae..af0a5feaa 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndDialog.cs @@ -14,11 +14,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions /// public class EndDialog : DialogAction { - /// - /// Gets or sets the property to return as the result ending the dialog. - /// - public string ResultProperty { get; set; } = "dialog.result"; - [JsonConstructor] public EndDialog(string resultProperty = null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base() @@ -31,6 +26,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions } } + /// + /// Gets or sets the property to return as the result ending the dialog. + /// + public string ResultProperty { get; set; } = "dialog.result"; + protected override async Task OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) { if (options is CancellationToken) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndTurn.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndTurn.cs index eb2435ec0..a3231add4 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndTurn.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/EndTurn.cs @@ -38,7 +38,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions throw new ArgumentException($"{nameof(options)} cannot be a cancellation token"); } - return Dialog.EndOfTurn; } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEach.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEach.cs index 53b70c933..065adbd07 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEach.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEach.cs @@ -22,12 +22,19 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions { private Expression listProperty; + [JsonConstructor] + public Foreach([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) + : base() + { + this.RegisterSourceLocation(sourceFilePath, sourceLineNumber); + } + // Expression used to compute the list that should be enumerated. [JsonProperty("listProperty")] public string ListProperty { get { return listProperty?.ToString(); } - set {this.listProperty = (value != null) ? new ExpressionEngine().Parse(value) : null; } + set { this.listProperty = (value != null) ? new ExpressionEngine().Parse(value) : null; } } // In-memory property that will contain the current items index. Defaults to `dialog.index`. @@ -42,11 +49,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions [JsonProperty("actions")] public List Actions { get; set; } = new List(); - [JsonConstructor] - public Foreach([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) - : base() + public override List ListDependencies() { - this.RegisterSourceLocation(sourceFilePath, sourceLineNumber); + return this.Actions; + } + + public class ForeachOptions + { + public Expression list { get; set; } + + public int offset { get; set; } } protected override async Task OnRunCommandAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) @@ -111,6 +123,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions } } + protected override string OnComputeId() + { + return $"{nameof(Foreach)}({this.ListProperty})"; + } + private object GetItem(object list, int index) { JToken result = null; @@ -125,23 +142,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions { result = ((JObject)list).SelectToken(index.ToString()); } - + return result; } - protected override string OnComputeId() - { - return $"{nameof(Foreach)}({this.ListProperty})"; - } - - public override List ListDependencies() - { - return this.Actions; - } - - public class ForeachOptions - { - public Expression list { get; set; } - public int offset { get; set; } - } } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEachPage.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEachPage.cs index c4cc194a2..556b7c727 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEachPage.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/ForEachPage.cs @@ -138,8 +138,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions } } } + return page; } + protected override string OnComputeId() { return $"{nameof(Foreach)}({this.ListProperty})"; @@ -153,7 +155,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions public class ForeachPageOptions { public Expression list { get; set; } + public int offset { get; set; } + public int pageSize { get; set; } } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/InitProperty.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/InitProperty.cs index a2cd7bae8..3632feddc 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/InitProperty.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/InitProperty.cs @@ -17,7 +17,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions public class InitProperty : DialogAction { [JsonConstructor] - public InitProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base() + public InitProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) + : base() { this.RegisterSourceLocation(callerPath, callerLine); } @@ -31,6 +32,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions { return OutputBinding; } + set { InputBindings[DialogContextState.DIALOG_VALUE] = value; @@ -50,7 +52,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions throw new ArgumentException($"{nameof(options)} cannot be a cancellation token"); } - // Ensure planning context if (dc is SequenceContext planning) { diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs index 02aabd8f0..862a814d7 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SetProperty.cs @@ -21,7 +21,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions private Expression property; [JsonConstructor] - public SetProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base() + public SetProperty([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) + : base() { this.RegisterSourceLocation(callerPath, callerLine); } @@ -33,7 +34,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions public string Value { get { return value?.ToString(); } - set {this.value = (value != null) ? new ExpressionEngine().Parse(value) : null; } + set { this.value = (value != null) ? new ExpressionEngine().Parse(value) : null; } } /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SwitchCondition.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SwitchCondition.cs index e9cacc4f6..f25461c5a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SwitchCondition.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SwitchCondition.cs @@ -82,7 +82,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions public string Condition { get { return condition?.ToString(); } - set {condition = (value != null) ? new ExpressionEngine().Parse(value) : null; } + set { condition = (value != null) ? new ExpressionEngine().Parse(value) : null; } } /// @@ -96,7 +96,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions public List Default { get; set; } = new List(); [JsonConstructor] - public SwitchCondition([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base() + public SwitchCondition([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) + : base() { this.RegisterSourceLocation(callerPath, callerLine); } @@ -132,7 +133,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions foreach (var caseCondition in this.Cases) { - var (value, error) = this.caseExpressions[caseCondition.Value].TryEvaluate(dc.State); if (error != null) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/TraceActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/TraceActivity.cs index ffffa5519..7afce4389 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/TraceActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/TraceActivity.cs @@ -16,7 +16,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions /// public class TraceActivity : DialogAction { - /// /// Name of the trace activity /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/AdaptiveDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/AdaptiveDialog.cs index 0379374d9..9a969593f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/AdaptiveDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/AdaptiveDialog.cs @@ -19,7 +19,6 @@ using static Microsoft.Bot.Builder.Dialogs.Debugging.DebugSupport; namespace Microsoft.Bot.Builder.Dialogs.Adaptive { - /// /// The Adaptive Dialog models conversation using events and events to adapt dynamicaly to changing conversation flow /// @@ -230,6 +229,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive handled = false; } } + break; } } @@ -457,7 +457,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive }, Entities = JObject.Parse("{}") }; - } } @@ -477,6 +476,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive return true; } } + return false; } @@ -521,6 +521,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive Selector = new FirstSelector() }; } + this.Selector.Initialize(this.Events, true); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/BotState.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/BotState.cs index dd68865c4..b1783190f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/BotState.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/BotState.cs @@ -11,6 +11,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive public class BotState : DialogState { public string LastAccess { get; set; } - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnActivity.cs index fe397d226..05238170e 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnActivity.cs @@ -11,7 +11,6 @@ using Newtonsoft.Json.Linq; namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events { - /// /// Event triggered when a Activity of a given type is received /// @@ -38,7 +37,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events protected override Expression BuildExpression(IExpressionParser factory) { - // add constraints for activity type return Expression.AndExpression(factory.Parse($"turn.dialogEvent.value.type == '{this.Type}'"), base.BuildExpression(factory)); @@ -62,5 +60,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events return $"{this.GetType().Name}({this.Type})[{this.Constraint}]"; } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnConversationUpdateActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnConversationUpdateActivity.cs index ffaff803e..fdf65c639 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnConversationUpdateActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnConversationUpdateActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnConversationUpdateActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.ConversationUpdate, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEndOfConversationActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEndOfConversationActivity.cs index 83bd976eb..0ba14e35d 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEndOfConversationActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEndOfConversationActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnEndOfConversationActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.EndOfConversation, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEvent.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEvent.cs index 3e5ab8dd0..77182b1e9 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEvent.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEvent.cs @@ -120,7 +120,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events throw new Exception($"Invalid constraint expression: {this.Constraint}, {e.Message}"); } } - } /// @@ -134,7 +133,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events return await OnExecuteAsync(planningContext).ConfigureAwait(false); } - /// /// Method called to process the request to execute the actions /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEventActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEventActivity.cs index d6b07cb8d..4cd810afd 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEventActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnEventActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnEventActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.Event, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnHandoffActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnHandoffActivity.cs index 4b3bb5add..187eca897 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnHandoffActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnHandoffActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnHandoffActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.Handoff, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnIntent.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnIntent.cs index 3b70e99f7..9537d185a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnIntent.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnIntent.cs @@ -42,7 +42,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events protected override Expression BuildExpression(IExpressionParser factory) { - // add constraints for the intents property if (string.IsNullOrEmpty(this.Intent)) { diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnInvokeActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnInvokeActivity.cs index 09e6d219c..1d60ce110 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnInvokeActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnInvokeActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnInvokeActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.Invoke, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageActivity.cs index 95b6a421c..98aef5b4b 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnMessageActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.Message, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageDeleteActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageDeleteActivity.cs index 7f3557751..a1bc10f19 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageDeleteActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageDeleteActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnMessageDeleteActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.MessageDelete, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageReactionActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageReactionActivity.cs index 3a07848c1..daf6df738 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageReactionActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageReactionActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnMessageReactionActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.MessageReaction, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageUpdateActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageUpdateActivity.cs index d707e526e..6a806c9be 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageUpdateActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnMessageUpdateActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnMessageUpdateActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.MessageUpdate, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnTypingActivity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnTypingActivity.cs index 427be998e..7473e0bd0 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnTypingActivity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Events/OnTypingActivity.cs @@ -17,5 +17,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Events public OnTypingActivity(List actions = null, string constraint= null, [CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0) : base(type: ActivityTypes.Typing, actions: actions, constraint: constraint, callerPath: callerPath, callerLine: callerLine) { } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs index c43b3c2bf..fe3ebca60 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/ChoiceInput.cs @@ -201,7 +201,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input } catch { - } if (choices == null || choices.Count == 0) @@ -213,7 +212,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input } catch { - } } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/DateTimeInput.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/DateTimeInput.cs index b62a8604d..f3a2c4fd5 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/DateTimeInput.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/DateTimeInput.cs @@ -8,7 +8,6 @@ using Microsoft.Bot.Schema; using Microsoft.Recognizers.Text.DateTime; using static Microsoft.Recognizers.Text.Culture; - namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input { public class DateTimeInput : InputDialog diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs index 1182c3a7e..3689564b7 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/InputDialog.cs @@ -104,6 +104,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input { return OutputBinding; } + set { InputBindings[DialogContextState.DIALOG_VALUE] = value; @@ -312,6 +313,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input { return await this.InvalidPrompt.BindToData(dc.Context, dc.State).ConfigureAwait(false); } + break; case InputState.Invalid: @@ -323,8 +325,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input { return await this.UnrecognizedPrompt.BindToData(dc.Context, dc.State).ConfigureAwait(false); } - break; + break; } return await this.Prompt.BindToData(dc.Context, dc.State); @@ -392,6 +394,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input return InputState.Invalid; } } + return InputState.Valid; } else diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs index d5deb2b8a..47293447c 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/OAuthInput.cs @@ -57,6 +57,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input { return OutputBinding; } + set { InputBindings[DialogContextState.DIALOG_VALUE] = value; diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/TextInput.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/TextInput.cs index b9c322cb4..bdba4128a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/TextInput.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Input/TextInput.cs @@ -13,7 +13,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input Trim, Lowercase, UpperCase - }; + } +; /// /// Declarative text input to gather text data from users diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Recognizers/MultiLanguageRecognizer.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Recognizers/MultiLanguageRecognizer.cs index b70086019..c79469d5d 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Recognizers/MultiLanguageRecognizer.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Recognizers/MultiLanguageRecognizer.cs @@ -13,7 +13,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers /// public class MultiLanguageRecognizer : IRecognizer { - /// /// Policy for languages fallback /// @@ -28,7 +27,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers public MultiLanguageRecognizer() { - } public Task RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken) @@ -43,6 +41,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers return recognizer.RecognizeAsync(turnContext, cancellationToken); } } + // nothing recognized return Task.FromResult(new RecognizerResult() { }); } @@ -59,6 +58,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers return recognizer.RecognizeAsync(turnContext, cancellationToken); } } + // nothing recognized return Task.FromResult(default(T)); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/ConditionalSelector.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/ConditionalSelector.cs index e77e83be5..bb9e7194c 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/ConditionalSelector.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/ConditionalSelector.cs @@ -24,7 +24,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors public string Condition { get { return condition?.ToString(); } - set {this.condition = (value != null) ? new ExpressionEngine().Parse(value) : null; } + set { this.condition = (value != null) ? new ExpressionEngine().Parse(value) : null; } } /// @@ -58,6 +58,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors selector = IfFalse; IfFalse.Initialize(_rules, _evaluate); } + return await selector.Select(context, cancel).ConfigureAwait(false); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/FirstSelector.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/FirstSelector.cs index c8293534e..a12fe37a8 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/FirstSelector.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/FirstSelector.cs @@ -47,11 +47,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors selection = 0; } } + var result = new List(); if (selection != -1) { result.Add(selection); } + return Task.FromResult((IReadOnlyList)result); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/MostSpecificSelector.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/MostSpecificSelector.cs index 94b8493f7..170127994 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/MostSpecificSelector.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/MostSpecificSelector.cs @@ -47,6 +47,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors matches.Add(pos); } } + selections = matches; } else @@ -59,11 +60,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors matches.Add((ValueTuple)trigger.Action); } } + // Sort rules by original order and then pass to child selector matches = (from candidate in matches orderby candidate.Item1 ascending select candidate).ToList(); Selector.Initialize(matches.Select(m => m.Item2), false); selections = (from match in await Selector.Select(context, cancel).ConfigureAwait(false) select matches[match].Item1).ToList(); } + return selections; } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/RandomSelector.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/RandomSelector.cs index 9e4366336..693e30c96 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/RandomSelector.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/RandomSelector.cs @@ -64,12 +64,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors candidates.Add(i); } } + var result = new List(); if (candidates.Count > 0) { var selection = _rand.Next(candidates.Count); result.Add(candidates[selection]); } + return Task.FromResult((IReadOnlyList)result); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/TrueSelector.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/TrueSelector.cs index 1e8eeceb0..83d3af4cf 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/TrueSelector.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Selectors/TrueSelector.cs @@ -44,6 +44,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors candidates.Add(i); } } + return Task.FromResult((IReadOnlyList)candidates); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/SequenceContext.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/SequenceContext.cs index 80bbfe879..d246c5512 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/SequenceContext.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/SequenceContext.cs @@ -101,6 +101,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive { this.Actions.Clear(); } + await EmitEventAsync(name: AdaptiveEvents.SequenceEnded, value: null, bubble: false).ConfigureAwait(false); break; case ActionChangeType.ReplaceSequence: @@ -108,6 +109,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive { this.Actions.Clear(); } + await UpdateSequenceAsync(change, cancellationToken).ConfigureAwait(false); break; } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/BaseEntityRecognizer.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/BaseEntityRecognizer.cs index 71fd0c42d..953cc3567 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/BaseEntityRecognizer.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/BaseEntityRecognizer.cs @@ -10,7 +10,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers { public BaseEntityRecognizer() { - } protected abstract List Recognize(string text, string culture); @@ -35,6 +34,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers } } } + return Task.FromResult((IList)newEntities); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/EntityRecognizerSet.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/EntityRecognizerSet.cs index 498edaa4b..bcf259bbf 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/EntityRecognizerSet.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/EntityRecognizerSet.cs @@ -6,7 +6,6 @@ using Microsoft.Bot.Schema; namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers { - /// /// EntityRecognizerSet - Implements a workflow against a pool of IEntityRecognizer instances, iterating until nobody has anything new to add. /// @@ -45,7 +44,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers { try { - // get new entities var newEntities = await recognizer.RecognizeEntities(turnContext, entitiesToProcess).ConfigureAwait(false); @@ -70,7 +68,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers // switch to next pool of new entities to process entitiesToProcess = newEntitiesToProcess; - } while (entitiesToProcess.Count > 0); return allNewEntities; diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/IEntityRecognizer.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/IEntityRecognizer.cs index 5ac1dde20..efb74bd76 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/IEntityRecognizer.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/IEntityRecognizer.cs @@ -9,7 +9,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition /// public interface IEntityRecognizer { - /// /// RecognizerEntities() - given a pool of entities and context add additional entities /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/OrdinalEntityRecognizer.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/OrdinalEntityRecognizer.cs index 3c267ec92..2fc1599ca 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/OrdinalEntityRecognizer.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/OrdinalEntityRecognizer.cs @@ -11,7 +11,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers { public OrdinalEntityRecognizer() { - } protected override List Recognize(string text, string culture) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/TextEntity.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/TextEntity.cs index f2c55b5f8..9ae04d46a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/TextEntity.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Composition/Recognizers/TextEntity.cs @@ -5,8 +5,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers public class TextEntity : Entity { public const string TypeName = "Text"; - public TextEntity() : base(TypeName) { } - public TextEntity(string text) : base(TypeName) + + public TextEntity() + : base(TypeName) { } + + public TextEntity(string text) + : base(TypeName) { Text = text; } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/CodeModel.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/CodeModel.cs index 5cbd67c26..fed679452 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/CodeModel.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/CodeModel.cs @@ -8,6 +8,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public interface ICodeModel { string NameFor(object item); + IReadOnlyList PointsFor(DialogContext dialogContext, object item, string more); } @@ -58,9 +59,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public interface ICodePoint { object Item { get; } + string More { get; } + string Name { get; } + object Data { get; } + object Evaluate(string expression); } @@ -75,11 +80,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging } private ICodeModel CodeModel { get; } + private DialogContext DialogContext { get; } + public object Item { get; } + public string More { get; } public string Name => CodeModel.NameFor(Item) + (More != null ? ":" + More : string.Empty); + public object Data { get diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Coercion.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Coercion.cs index 01a35df2a..5627be65a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Coercion.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Coercion.cs @@ -16,6 +16,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public Coercion() { } + object ICoercion.Coerce(object source, Type target) { var token = source as JToken; diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DataModel.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DataModel.cs index 23c08ba21..9b257620e 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DataModel.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DataModel.cs @@ -12,130 +12,189 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging get; set; } + int Rank { get; } + bool IsScalar(object context); + IEnumerable Names(object context); + string ToString(object context); } + public sealed class NullDataModel : IDataModel { public static readonly IDataModel Instance = new NullDataModel(); + private NullDataModel() { } + object IDataModel.this[object context, object name] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); } + int IDataModel.Rank => 0; + bool IDataModel.IsScalar(object context) => true; + IEnumerable IDataModel.Names(object context) => Enumerable.Empty(); + string IDataModel.ToString(object context) => "null"; } + public sealed class ScalarDataModel : IDataModel { public static readonly IDataModel Instance = new ScalarDataModel(); + private ScalarDataModel() { } + object IDataModel.this[object context, object name] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); } + int IDataModel.Rank => 1; + bool IDataModel.IsScalar(object context) => true; + IEnumerable IDataModel.Names(object context) => Enumerable.Empty(); + string IDataModel.ToString(object context) => context.ToString(); } + public abstract class DataModelBase : IDataModel { private readonly ICoercion coercion; + protected DataModelBase(ICoercion coercion) { this.coercion = coercion ?? throw new ArgumentNullException(nameof(coercion)); } + protected T Coerce(object item) => (T)this.coercion.Coerce(item, typeof(T)); + public abstract int Rank { get; } + public abstract Value this[Context context, Name name] { get; set; } + public virtual bool IsScalar(Context context) => false; + public abstract IEnumerable Names(Context context); + public virtual string ToString(Context context) => (context is ICollection collection) ? $"Count = {collection.Count}" : context.ToString(); + object IDataModel.this[object context, object name] { get => this[(Context)context, Coerce(name)]; set => this[(Context)context, Coerce(name)] = Coerce(value); } + bool IDataModel.IsScalar(object context) => IsScalar((Context)context); + string IDataModel.ToString(object context) => ToString((Context)context); + IEnumerable IDataModel.Names(object context) => Names((Context)context).Cast(); } + public sealed class DictionaryDataModel : DataModelBase, K, V> { - public DictionaryDataModel(ICoercion coercion) : base(coercion) { } + public DictionaryDataModel(ICoercion coercion) + : base(coercion) { } + public override int Rank => 6; + public override V this[IDictionary context, K name] { get => context[name]; set => context[name] = value; } + public override IEnumerable Names(IDictionary context) => context.Keys; } + public sealed class ReadOnlyDictionaryDataModel : DataModelBase, K, V> { - public ReadOnlyDictionaryDataModel(ICoercion coercion) : base(coercion) { } + public ReadOnlyDictionaryDataModel(ICoercion coercion) + : base(coercion) { } + public override int Rank => 5; + public override V this[IReadOnlyDictionary context, K name] { get => context[name]; set => throw new NotSupportedException(); } + public override IEnumerable Names(IReadOnlyDictionary context) => context.Keys; } + public sealed class ListDataModel : DataModelBase, int, T> { - public ListDataModel(ICoercion coercion) : base(coercion) { } + public ListDataModel(ICoercion coercion) + : base(coercion) { } + public override int Rank => 4; + public override T this[IList context, int name] { get => context[name]; set => context[name] = value; } + public override IEnumerable Names(IList context) => Enumerable.Range(0, context.Count); } + public sealed class EnumerableDataModel : DataModelBase, int, T> { - public EnumerableDataModel(ICoercion coercion) : base(coercion) { } + public EnumerableDataModel(ICoercion coercion) + : base(coercion) { } + public override int Rank => 3; + public override T this[IEnumerable context, int name] { get => context.ElementAt(name); set => throw new NotSupportedException(); } + public override IEnumerable Names(IEnumerable context) => context.Select((_, index) => index); } + public sealed class ReflectionDataModel : DataModelBase { - public ReflectionDataModel(ICoercion coercion) : base(coercion) { } + public ReflectionDataModel(ICoercion coercion) + : base(coercion) { } + public override int Rank => 2; + public override object this[object context, string name] { get => context.GetType().GetProperty(name).GetValue(context); set => context.GetType().GetProperty(name).SetValue(context, value); } + public override IEnumerable Names(object context) => context.GetType().GetProperties().Where(p => p.GetIndexParameters().Length == 0).Select(p => p.Name); } + public sealed class DataModel : IDataModel { private readonly ICoercion coercion; + public DataModel(ICoercion coercion) { this.coercion = coercion ?? throw new ArgumentNullException(nameof(coercion)); } private readonly Dictionary modelByType = new Dictionary(); + private IDataModel Create(Type definition, params Type[] typeArguments) => (IDataModel)Activator.CreateInstance(definition.MakeGenericType(typeArguments), this.coercion); + private IEnumerable Options(Type type) { if (type.IsPrimitive || type == typeof(string)) @@ -175,6 +234,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging yield return Create(typeof(ReflectionDataModel<>), type); } } + private IDataModel ModelFor(object context) { if (context == null) @@ -192,14 +252,19 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging return model; } + int IDataModel.Rank => int.MaxValue; + object IDataModel.this[object context, object name] { get => ModelFor(context)[context, name]; set => ModelFor(context)[context, name] = value; } + bool IDataModel.IsScalar(object context) => ModelFor(context).IsScalar(context); + IEnumerable IDataModel.Names(object context) => ModelFor(context).Names(context); + string IDataModel.ToString(object context) => ModelFor(context).ToString(context); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebugAdapter.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebugAdapter.cs index 20ac994e8..db22db26b 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebugAdapter.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebugAdapter.cs @@ -37,15 +37,25 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging TurnContext = turnContext; CodeModel = codeModel; } + public ITurnContext TurnContext { get; } + public ICodeModel CodeModel { get; } + public string Name => TurnContext.Activity.Text; + public IReadOnlyList Frames => CodeModel.PointsFor(LastContext, LastItem, LastMore); + public RunModel Run { get; } = new RunModel(); + public Identifier FrameCodes { get; } = new Identifier(); + public Identifier ValueCodes { get; } = new Identifier(); + public DialogContext LastContext { get; set; } + public object LastItem { get; set; } + public string LastMore { get; set; } } @@ -54,7 +64,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public sealed class RunModel { public Phase? PhaseSent { get; set; } + public Phase Phase { get; set; } = Phase.Started; + public object Gate { get; } = new object(); public void Post(Phase what) @@ -327,6 +339,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging } private int sequence = 0; + private int NextSeq => Interlocked.Increment(ref sequence); private Protocol.Capabilities MakeCapabilities() diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebuggingAdapterExtensions.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebuggingAdapterExtensions.cs index a5966c2dc..c8165249b 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebuggingAdapterExtensions.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/DebuggingAdapterExtensions.cs @@ -35,7 +35,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging dataModel: dataModel, logger: logger)); } - - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Extensions.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Extensions.cs index 4a5d73082..f8dd7b1e0 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Extensions.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Extensions.cs @@ -11,10 +11,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public struct Releaser : IDisposable { public SemaphoreSlim Semaphore { get; } + public Releaser(SemaphoreSlim semaphore) { Semaphore = semaphore ?? throw new ArgumentNullException(nameof(semaphore)); } + public void Dispose() { Semaphore.Release(); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Identifier.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Identifier.cs index abf98507b..f2b2c4966 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Identifier.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Identifier.cs @@ -10,10 +10,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public sealed class ReferenceEquality : IEqualityComparer { public static readonly IEqualityComparer Instance = new ReferenceEquality(); + private ReferenceEquality() { } + bool IEqualityComparer.Equals(T x, T y) => object.ReferenceEquals(x, y); + int IEqualityComparer.GetHashCode(T obj) => RuntimeHelpers.GetHashCode(obj); } @@ -21,6 +24,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging { private const ulong MORE = 0x80; private const ulong DATA = 0x7F; + private static void Encode(ulong source, ref ulong target, ref int offset) { while (source > DATA) @@ -37,6 +41,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging offset += 8; } } + private static void Decode(ref ulong source, out ulong target) { target = 0; @@ -55,6 +60,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging offset += 7; } } + public static ulong Encode(ulong one, ulong two) { ulong target = 0; @@ -102,6 +108,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging return code; } } + public void Remove(T item) { lock (gate) @@ -143,6 +150,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging } } } + public ulong this[T item] { get diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Protocol.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Protocol.cs index 93824af30..cab0357c7 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Protocol.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/Protocol.cs @@ -16,7 +16,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public abstract class Message { public int seq { get; set; } + public string type { get; set; } + [JsonExtensionData] public JObject Rest { get; set; } } @@ -24,6 +26,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public class Request : Message { public string command { get; set; } + public override string ToString() => command; } @@ -31,108 +34,153 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging { public Arguments arguments { get; set; } } + public class Attach { } + public class Launch { } + public class Initialize { public string clientID { get; set; } + public string clientName { get; set; } + public string adapterID { get; set; } + public string pathFormat { get; set; } + public bool linesStartAt1 { get; set; } + public bool columnsStartAt1 { get; set; } + public bool supportsVariableType { get; set; } + public bool supportsVariablePaging { get; set; } + public bool supportsRunInTerminalRequest { get; set; } + public string locale { get; set; } } public class SetBreakpoints { public Source source { get; set; } + public SourceBreakpoint[] breakpoints { get; set; } + public bool sourceModified { get; set; } } + public class SetFunctionBreakpoints { public FunctionBreakpoint[] breakpoints { get; set; } } + public class SetExceptionBreakpoints { public string[] filters { get; set; } } + public class Threads { } + public class Capabilities { public bool supportsConfigurationDoneRequest { get; set; } + public bool supportsSetVariable { get; set; } + public bool supportsEvaluateForHovers { get; set; } + public bool supportsFunctionBreakpoints { get; set; } + public ExceptionBreakpointFilter[] exceptionBreakpointFilters { get; set; } + public bool supportTerminateDebuggee { get; set; } + public bool supportsTerminateRequest { get; set; } } + public class ExceptionBreakpointFilter { public string filter { get; set; } + public string label { get; set; } + public bool @default { get; set; } } + public abstract class PerThread { public ulong threadId { get; set; } } + public class StackTrace : PerThread { public int? startFrame { get; set; } + public int? levels { get; set; } } + public class Continue : PerThread { } + public class Pause : PerThread { } + public class Next : PerThread { } + public class Scopes { public ulong frameId { get; set; } } + public class Variables { public ulong variablesReference { get; set; } } + public class SetVariable { public ulong variablesReference { get; set; } + public string name { get; set; } + public string value { get; set; } } + public class Evaluate { public ulong frameId { get; set; } + public string expression { get; set; } } + public class ConfigurationDone { } + public class Disconnect { public bool restart { get; set; } + public bool terminateDebuggee { get; set; } } + public class Terminate { public bool restart { get; set; } } + public class Event : Message { public Event(int seq, string @event) @@ -141,15 +189,19 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging this.type = "event"; this.@event = @event; } + public string @event { get; set; } + public static Event From(int seq, string @event, Body body) => new Event(seq, @event) { body = body }; } + public class Event : Event { public Event(int seq, string @event) : base(seq, @event) { } + public Body body { get; set; } } @@ -163,11 +215,17 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging this.success = true; this.command = request.command; } + public int request_seq { get; set; } + public bool success { get; set; } + public string message { get; set; } + public string command { get; set; } + public static Response From(int seq, Request request, Body body) => new Response(seq, request) { body = body }; + public static Response Fail(int seq, Request request, string message) => new Response(seq, request) { body = message, message = message, success = false }; } @@ -177,6 +235,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging : base(seq, request) { } + public Body body { get; set; } } @@ -188,15 +247,20 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public class Range : Reference { public Source source { get; set; } + public int? line { get; set; } + public int? column { get; set; } + public int? endLine { get; set; } + public int? endColumn { get; set; } } public class Breakpoint : Range { public bool verified { get; set; } + public string message { get; set; } } @@ -219,12 +283,15 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging } public string name { get; set; } + public string path { get; set; } } + public sealed class SourceBreakpoint { public int line { get; set; } } + public sealed class FunctionBreakpoint { public string name { get; set; } @@ -259,6 +326,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging case "disconnect": return token.ToObject>(); default: return token.ToObject(); } + default: throw new NotImplementedException(); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/SourceMap.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/SourceMap.cs index 142aca8cc..167384ece 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/SourceMap.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Debugging/SourceMap.cs @@ -9,9 +9,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public interface IBreakpoints { bool IsBreakPoint(object item); + object ItemFor(Protocol.Breakpoint breakpoint); + IReadOnlyList SetBreakpoints(Protocol.Source source, IReadOnlyList sourceBreakpoints); + IReadOnlyList SetBreakpoints(IReadOnlyList functionBreakpoints); + IReadOnlyList ApplyUpdates(); } @@ -64,14 +68,20 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging Source = source; SourceBreakpoint = sourceBreakpoint; } + public Row(Protocol.FunctionBreakpoint functionBreakpoint) { FunctionBreakpoint = functionBreakpoint; } + public Protocol.Source Source { get; } + public Protocol.SourceBreakpoint SourceBreakpoint { get; } + public Protocol.FunctionBreakpoint FunctionBreakpoint { get; } + public Protocol.Breakpoint Breakpoint { get; } = new Protocol.Breakpoint(); + public object item { get; set; } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ActivityConverter.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ActivityConverter.cs index 01f7cccaa..d45f93310 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ActivityConverter.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ActivityConverter.cs @@ -32,6 +32,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters Text = (string)reader.Value }; } + return JToken.Load(reader).ToObject(); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ExpressionConverter.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ExpressionConverter.cs index db3662520..4b2b33b5e 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ExpressionConverter.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/ExpressionConverter.cs @@ -23,6 +23,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters { return new ExpressionEngine().Parse((string)reader.Value); } + throw new JsonSerializationException("Expected string expression."); } @@ -31,5 +32,4 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters serializer.Serialize(writer, value); } } - } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/LanguageGeneratorConverter.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/LanguageGeneratorConverter.cs index 97ebfa2b8..c480bd5b3 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/LanguageGeneratorConverter.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Converters/LanguageGeneratorConverter.cs @@ -15,7 +15,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters { public class LanguageGeneratorConverter : InterfaceConverter { - public LanguageGeneratorConverter(IRefResolver refResolver, Source.IRegistry registry, Stack paths) : base(refResolver, registry, paths) { } @@ -27,6 +26,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Converters string readerValue = reader.Value.ToString(); return TypeFactory.Build("DefaultLanguageGenerator", readerValue, serializer); } + return base.ReadJson(reader, objectType, existingValue, serializer); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/DeclarativeTypeLoader.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/DeclarativeTypeLoader.cs index d33979cae..d60c8072e 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/DeclarativeTypeLoader.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/DeclarativeTypeLoader.cs @@ -88,9 +88,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative { path = path.Substring(9); } + // just use configurations ability to query for x:y:z value = ConfigurationBinder.GetValue(configuration, path); } + return value; } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/FileDependencyInfo.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/FileDependencyInfo.cs index 707b8a6bc..fd010873c 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/FileDependencyInfo.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/FileDependencyInfo.cs @@ -6,8 +6,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Plugins public class FileDependencyInfo { public string AssemblyPath { get; set; } + public string SchemaUri { get; set; } + public string ClassName { get; set; } + public string CustomLoaderClassName { get; set; } } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/IPlugin.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/IPlugin.cs index d50de8004..7a45551b5 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/IPlugin.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Plugins/IPlugin.cs @@ -10,8 +10,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Plugins public interface IPlugin { string SchemaUri { get; } + Type Type { get; } + ICustomDeserializer Loader { get; } + Task Load(); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/IdRefResolver.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/IdRefResolver.cs index dd70b2cff..6f128766d 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/IdRefResolver.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/IdRefResolver.cs @@ -53,12 +53,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resolvers JObject targetProperty = json[prop.Name] as JObject; targetProperty.Merge(prop.Value); } + // JToken is an object, so we merge objects else if (json[prop.Name] != null && json[prop.Name].Type == JTokenType.Array) { JArray targetArray = json[prop.Name] as JArray; targetArray.Merge(prop.Value); } + // JToken is a value, simply assign else { @@ -84,6 +86,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resolvers { return token.Value(); } + // Else try to get a reference from the token return token? .Children() diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/JPointerRefResolver.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/JPointerRefResolver.cs index 930343728..45f36e1d6 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/JPointerRefResolver.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resolvers/JPointerRefResolver.cs @@ -73,12 +73,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resolvers JObject targetProperty = json[prop.Name] as JObject; targetProperty.Merge(prop.Value); } + // JToken is an object, so we merge objects else if (json[prop.Name] != null && json[prop.Name].Type == JTokenType.Array) { JArray targetArray = json[prop.Name] as JArray; targetArray.Merge(prop.Value); } + // JToken is a value, simply assign else { diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FileResource.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FileResource.cs index dfbe51023..b2815bbbf 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FileResource.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FileResource.cs @@ -71,6 +71,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources return await textReader.ReadToEndAsync().ConfigureAwait(false); }); } + return this.textTask; } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FolderResourceProvider.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FolderResourceProvider.cs index 131515cf8..45542492a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FolderResourceProvider.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/FolderResourceProvider.cs @@ -11,7 +11,6 @@ using System.Threading.Tasks; namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources { - /// /// Folder/FileResources /// @@ -129,7 +128,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources } } - /// /// GetResource by id /// @@ -169,7 +167,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources public static class FolderResourceProviderExtensions { - /// /// Add a folder resource /// @@ -211,8 +208,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources { explorer.AddFolder(folder, includeSubFolders: true, monitorChanges: monitorChanges); } + return explorer; } - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/IResource.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/IResource.cs index b8797e791..219987dfa 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/IResource.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/IResource.cs @@ -24,6 +24,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources /// /// Task OpenStreamAsync(); - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/ResourceExplorer.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/ResourceExplorer.cs index e62c23afb..f910c8e56 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/ResourceExplorer.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Resources/ResourceExplorer.cs @@ -95,6 +95,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources throw new ArgumentNullException(nameof(projectFile)); } } + string projectFolder = Path.GetDirectoryName(projectFile); XmlDocument xmlDoc = new XmlDocument(); @@ -121,6 +122,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources explorer.AddResourceProvider(new FolderResourceProvider(path, includeSubFolders: true, monitorChanges: monitorChanges)); } } + var packages = Path.GetFullPath("packages"); var relativePackagePath = Path.Combine(@"..", "packages"); while (!Directory.Exists(packages) && Path.GetDirectoryName(packages) != Path.GetPathRoot(packages)) @@ -131,6 +133,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources throw new ArgumentNullException("Can't find packages folder"); } } + var pathResolver = new PackagePathResolver(packages); // add nuget package references @@ -184,6 +187,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources return resource; } } + return null; } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/Factory.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/Factory.cs index 3cd14eb53..e9b0775a8 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/Factory.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/Factory.cs @@ -77,6 +77,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Types { throw new ArgumentException($"Type {name} not registered in factory."); } + var found = builders.TryGetValue(type, out builder); if (!found) diff --git a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/UriTypeBinder.cs b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/UriTypeBinder.cs index 981914760..2348e9a3b 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/UriTypeBinder.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs.Declarative/Types/UriTypeBinder.cs @@ -29,6 +29,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Types { return type; } + return base.BindToType(assemblyName, typeName); } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs index 356f4843d..8f39faefc 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/ComponentDialog.cs @@ -100,15 +100,6 @@ namespace Microsoft.Bot.Builder.Dialogs } } - protected async Task EnsureInitialized(DialogContext outerDc) - { - if (!this.initialized) - { - this.initialized = true; - await OnInitialize(outerDc).ConfigureAwait(false); - } - } - public override async Task ResumeDialogAsync(DialogContext outerDc, DialogReason reason, object result = null, CancellationToken cancellationToken = default(CancellationToken)) { if (result is CancellationToken) @@ -184,26 +175,13 @@ namespace Microsoft.Bot.Builder.Dialogs return childDc; } - private DialogContext CreateInnerDc(ITurnContext context, DialogInstance instance, IDictionary userState, IDictionary conversationState) + protected async Task EnsureInitialized(DialogContext outerDc) { - DialogState state; - - if (instance.State.ContainsKey(PersistedDialogState)) + if (!this.initialized) { - state = instance.State[PersistedDialogState] as DialogState; + this.initialized = true; + await OnInitialize(outerDc).ConfigureAwait(false); } - else - { - state = new DialogState(); - instance.State[PersistedDialogState] = state; - } - - if (state.DialogStack == null) - { - state.DialogStack = new List(); - } - - return new DialogContext(this._dialogs, context, state, conversationState, userState); } protected virtual Task OnInitialize(DialogContext dc) @@ -245,5 +223,27 @@ namespace Microsoft.Bot.Builder.Dialogs { return $"component[{this.BindingPath()}]"; } + + private DialogContext CreateInnerDc(ITurnContext context, DialogInstance instance, IDictionary userState, IDictionary conversationState) + { + DialogState state; + + if (instance.State.ContainsKey(PersistedDialogState)) + { + state = instance.State[PersistedDialogState] as DialogState; + } + else + { + state = new DialogState(); + instance.State[PersistedDialogState] = state; + } + + if (state.DialogStack == null) + { + state.DialogStack = new List(); + } + + return new DialogContext(this._dialogs, context, state, conversationState, userState); + } } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/ConfigurationHelper.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Configuration.cs similarity index 99% rename from libraries/Microsoft.Bot.Builder.Dialogs/ConfigurationHelper.cs rename to libraries/Microsoft.Bot.Builder.Dialogs/Configuration.cs index d2c65bf4f..39ce1340c 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/ConfigurationHelper.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Configuration.cs @@ -6,7 +6,6 @@ using Microsoft.Extensions.Configuration; namespace Microsoft.Bot.Builder.Dialogs { - public static class Configuration { /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/DebugSupport.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/DebugSupport.cs index 9e3733fea..e83bc1661 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/DebugSupport.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/DebugSupport.cs @@ -10,13 +10,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging { public static partial class DebugSupport { - public static IRegistry SourceRegistry { get; set; } = NullRegistry.Instance; - public interface IDebugger { Task StepAsync(DialogContext context, object item, string more, CancellationToken cancellationToken); } + public static IRegistry SourceRegistry { get; set; } = NullRegistry.Instance; + public static IDebugger GetDebugger(this ITurnContext context) => context.TurnState.Get() ?? NullDebugger.Instance; diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/Source.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/Source.cs index 08a85608c..59e7b6769 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/Source.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Debugging/Source.cs @@ -13,6 +13,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging { public struct Point { + public int LineIndex { get; set; } + + public int CharIndex { get; set; } + public static Point From(JsonReader reader) => (reader is IJsonLineInfo info) ? new Point() { LineIndex = info.LineNumber, CharIndex = info.LinePosition } @@ -34,13 +38,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging return item; } - public int LineIndex { get; set; } - - public int CharIndex { get; set; } - public override string ToString() => $"{LineIndex}:{CharIndex}"; } + public interface IRegistry + { + void Add(object item, Range range); + + bool TryGetValue(object item, out Range range); + } + public sealed class Range { public string Path { get; set; } @@ -52,13 +59,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging public override string ToString() => $"{System.IO.Path.GetFileName(Path)}:{Start}->{After}"; } - public interface IRegistry - { - void Add(object item, Range range); - - bool TryGetValue(object item, out Range range); - } - public sealed class NullRegistry : IRegistry { public static readonly IRegistry Instance = new NullRegistry(); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs index 5b42f6234..4c007e56e 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Dialog.cs @@ -20,6 +20,8 @@ namespace Microsoft.Bot.Builder.Dialogs private IBotTelemetryClient _telemetryClient; + private string id; + /// /// Initializes a new instance of the class. /// Called from constructors in derived classes to initialize the class. @@ -31,8 +33,6 @@ namespace Microsoft.Bot.Builder.Dialogs _telemetryClient = NullBotTelemetryClient.Instance; } - private string id; - /// /// Unique id for the dialog. /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/DialogContext.cs b/libraries/Microsoft.Bot.Builder.Dialogs/DialogContext.cs index 4e9cbc9ac..f7cb18e2e 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/DialogContext.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/DialogContext.cs @@ -480,6 +480,7 @@ namespace Microsoft.Bot.Builder.Dialogs await EndActiveDialogAsync(DialogReason.ReplaceCalled, cancellationToken: cancellationToken).ConfigureAwait(false); this.State.Turn["__repeatDialogId"] = dialogId; + // Start replacement dialog return await BeginDialogAsync(dialogId, options, cancellationToken).ConfigureAwait(false); } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/DialogContextState.cs b/libraries/Microsoft.Bot.Builder.Dialogs/DialogContextState.cs index df71632e8..003a4c07f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/DialogContextState.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/DialogContextState.cs @@ -13,24 +13,9 @@ using Newtonsoft.Json.Serialization; namespace Microsoft.Bot.Builder.Dialogs { - /// - /// Defines the shape of the state object returned by calling DialogContext.State.ToJson() - /// - public class DialogContextVisibleState - { - [JsonProperty(PropertyName = "user")] - public IDictionary User { get; set; } - - [JsonProperty(PropertyName = "conversation")] - public IDictionary Conversation { get; set; } - - [JsonProperty(PropertyName = "dialog")] - public IDictionary Dialog { get; set; } - } - public class DialogContextState : IDictionary { - private const string prefixCallBack = "callstackScope('"; + private const string PrefixCallBack = "callstackScope('"; private static JsonSerializerSettings expressionCaseSettings = new JsonSerializerSettings { @@ -40,15 +25,6 @@ namespace Microsoft.Bot.Builder.Dialogs private readonly DialogContext dialogContext; - public DialogContextState(DialogContext dc, IDictionary settings, IDictionary userState, IDictionary conversationState, IDictionary turnState) - { - this.dialogContext = dc ?? throw new ArgumentNullException(nameof(dc)); - this.Settings = settings; - this.User = userState; - this.Conversation = conversationState; - this.Turn = turnState; - } - /// /// Common state properties paths. /// @@ -64,6 +40,15 @@ namespace Microsoft.Bot.Builder.Dialogs public const string STEP_OPTIONS_PROPERTY = "dialog.step.options"; + public DialogContextState(DialogContext dc, IDictionary settings, IDictionary userState, IDictionary conversationState, IDictionary turnState) + { + this.dialogContext = dc ?? throw new ArgumentNullException(nameof(dc)); + this.Settings = settings; + this.User = userState; + this.Conversation = conversationState; + this.Turn = turnState; + } + /// /// Gets or sets settings for the application. /// @@ -319,10 +304,10 @@ namespace Microsoft.Bot.Builder.Dialogs } var e = pathExpression.ToString(); - if (e.StartsWith(prefixCallBack)) + if (e.StartsWith(PrefixCallBack)) { // turn $foo which comes in as callbackStack('foo') => dialog.foo - pathExpression = new ExpressionEngine().Parse($"dialog.{e.Substring(prefixCallBack.Length, e.Length - prefixCallBack.Length - 2)}"); + pathExpression = new ExpressionEngine().Parse($"dialog.{e.Substring(PrefixCallBack.Length, e.Length - PrefixCallBack.Length - 2)}"); } ObjectPath.SetValue(this, pathExpression, value); @@ -424,4 +409,19 @@ namespace Microsoft.Bot.Builder.Dialogs throw new NotImplementedException(); } } + + /// + /// Defines the shape of the state object returned by calling DialogContext.State.ToJson() + /// + public class DialogContextVisibleState + { + [JsonProperty(PropertyName = "user")] + public IDictionary User { get; set; } + + [JsonProperty(PropertyName = "conversation")] + public IDictionary Conversation { get; set; } + + [JsonProperty(PropertyName = "dialog")] + public IDictionary Dialog { get; set; } + } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/DialogManager.cs b/libraries/Microsoft.Bot.Builder.Dialogs/DialogManager.cs index f6be0cf6a..198d0135d 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/DialogManager.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/DialogManager.cs @@ -148,7 +148,7 @@ namespace Microsoft.Bot.Builder.Dialogs { await storage.WriteAsync(new Dictionary() { - { keys.UserState, newState.UserState}, + { keys.UserState, newState.UserState }, { keys.ConversationState, newState.ConversationState }, { keys.DialogState, newState.DialogStack }, }).ConfigureAwait(false); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/DialogManagerAdapter.cs b/libraries/Microsoft.Bot.Builder.Dialogs/DialogManagerAdapter.cs index 5bea0a8b8..937df0129 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/DialogManagerAdapter.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/DialogManagerAdapter.cs @@ -8,14 +8,14 @@ using Microsoft.Bot.Schema; namespace Microsoft.Bot.Builder.Dialogs { - class DialogManagerAdapter : BotAdapter + public class DialogManagerAdapter : BotAdapter { + public readonly List Activities = new List(); + public DialogManagerAdapter() { } - public readonly List Activities = new List(); - public override Task SendActivitiesAsync(ITurnContext turnContext, Activity[] activities, CancellationToken cancellationToken) { this.Activities.AddRange(activities); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/IDialog.cs b/libraries/Microsoft.Bot.Builder.Dialogs/IDialog.cs index 15e40fdfd..2b345184f 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/IDialog.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/IDialog.cs @@ -91,7 +91,6 @@ namespace Microsoft.Bot.Builder.Dialogs /// Task EndDialogAsync(ITurnContext turnContext, DialogInstance instance, DialogReason reason, CancellationToken cancellationToken = default(CancellationToken)); - /// /// Called when an event has been raised, using `DialogContext.emitEvent()`, by either the current dialog or a dialog that the current dialog started. /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/LowercaseCasingStrategy.cs b/libraries/Microsoft.Bot.Builder.Dialogs/LowercaseNamingStrategy.cs similarity index 100% rename from libraries/Microsoft.Bot.Builder.Dialogs/LowercaseCasingStrategy.cs rename to libraries/Microsoft.Bot.Builder.Dialogs/LowercaseNamingStrategy.cs diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/StoredBotState.cs b/libraries/Microsoft.Bot.Builder.Dialogs/StoredBotState.cs index b1c7202e0..a1c05cf7a 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/StoredBotState.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/StoredBotState.cs @@ -8,7 +8,9 @@ namespace Microsoft.Bot.Builder.Dialogs public class StoredBotState { public IDictionary UserState { get; set; } + public IDictionary ConversationState { get; set; } + public IList DialogStack { get; set; } } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/Templating/ActivityTemplate.cs b/libraries/Microsoft.Bot.Builder.Dialogs/Templating/ActivityTemplate.cs index 5b763cf6b..ba53682d6 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/Templating/ActivityTemplate.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/Templating/ActivityTemplate.cs @@ -6,7 +6,6 @@ using Microsoft.Bot.Schema; namespace Microsoft.Bot.Builder.Dialogs { - /// /// Defines an activity Template where the template expression is local aka "inline". /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/templating/IActivityTemplate.cs b/libraries/Microsoft.Bot.Builder.Dialogs/templating/IActivityTemplate.cs index 55bb58b43..65e0420c6 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/templating/IActivityTemplate.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/templating/IActivityTemplate.cs @@ -7,6 +7,5 @@ namespace Microsoft.Bot.Builder.Dialogs /// public interface IActivityTemplate : ITemplate { - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/templating/ITextTemplate.cs b/libraries/Microsoft.Bot.Builder.Dialogs/templating/ITextTemplate.cs index bbbaff6db..334a38fac 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/templating/ITextTemplate.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/templating/ITextTemplate.cs @@ -5,6 +5,5 @@ /// public interface ITextTemplate : ITemplate { - } } diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/templating/StaticActivityTemplate.cs b/libraries/Microsoft.Bot.Builder.Dialogs/templating/StaticActivityTemplate.cs index 4e6a71749..12b3db102 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/templating/StaticActivityTemplate.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/templating/StaticActivityTemplate.cs @@ -5,7 +5,6 @@ using Microsoft.Bot.Schema; namespace Microsoft.Bot.Builder.Dialogs { - /// /// Defins a static activity as a template. /// diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextMessageActivityGenerator.cs b/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextMessageActivityGenerator.cs index 1e0ef6f8c..6f8d5ae16 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextMessageActivityGenerator.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextMessageActivityGenerator.cs @@ -127,7 +127,7 @@ namespace Microsoft.Bot.Builder.Dialogs } } - if (!String.IsNullOrEmpty(line)) + if (!string.IsNullOrEmpty(line)) { var i = line.IndexOf("||"); if (i > 0) @@ -155,78 +155,7 @@ namespace Microsoft.Bot.Builder.Dialogs return activity; } - private async Task AddAttachment(ITurnContext turnContext, ILanguageGenerator languageGenerator, IMessageActivity activity, string line, object data) - { - var parts = line.Split('='); - if (parts.Length == 1) - { - throw new ArgumentOutOfRangeException($"Missing = seperator in {line}"); - } - - var value = parts[1].TrimEnd(']').Trim(); - var parts2 = value.Split(' '); - var contentUrl = parts2[0]; - var attachment = new Attachment(contentUrl: contentUrl); - - if (parts2.Length == 2) - { - switch (parts2[1].ToLower()) - { - case "animation": - attachment.ContentType = AnimationCard.ContentType; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - case "audio": - attachment.ContentType = AudioCard.ContentType; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - case "hero": - attachment.ContentType = HeroCard.ContentType; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - case "receipt": - attachment.ContentType = ReceiptCard.ContentType; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - case "thumbnail": - attachment.ContentType = ThumbnailCard.ContentType; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - case "signin": - attachment.ContentType = SigninCard.ContentType; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - case "video": - attachment.ContentType = VideoCard.ContentType; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - case "adaptivecard": - attachment.ContentType = "application/vnd.microsoft.card.adaptive"; - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); - break; - default: - attachment.ContentType = parts2[1].Trim(); - attachment.Content = await readAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: false, data: data).ConfigureAwait(false); - break; - } - } - - if (attachment.Content != null && attachment.Content is string && ((string)attachment.Content).StartsWith("data:")) - { - attachment.ContentUrl = (string)attachment.Content; - attachment.Content = null; - } - - if (attachment.Content != null) - { - // if we are sending content, then no need for contentUrl - attachment.ContentUrl = null; - } - - activity.Attachments.Add(attachment); - } - - protected async Task readAttachmentFile(ITurnContext turnContext, ILanguageGenerator languageGenerator, string fileLocation, string contentType, bool isCard, object data) + protected async Task ReadAttachmentFile(ITurnContext turnContext, ILanguageGenerator languageGenerator, string fileLocation, string contentType, bool isCard, object data) { if (Uri.TryCreate(fileLocation, UriKind.Absolute, out Uri uri)) { @@ -250,7 +179,7 @@ namespace Microsoft.Bot.Builder.Dialogs if (languageGeneratorr != null) { var template = $"```\n{jsonContents}\n```"; - + // databind json var result = await languageGenerator.Generate(turnContext, template, data).ConfigureAwait(false); if (result != null) @@ -271,6 +200,77 @@ namespace Microsoft.Bot.Builder.Dialogs } } + private async Task AddAttachment(ITurnContext turnContext, ILanguageGenerator languageGenerator, IMessageActivity activity, string line, object data) + { + var parts = line.Split('='); + if (parts.Length == 1) + { + throw new ArgumentOutOfRangeException($"Missing = seperator in {line}"); + } + + var value = parts[1].TrimEnd(']').Trim(); + var parts2 = value.Split(' '); + var contentUrl = parts2[0]; + var attachment = new Attachment(contentUrl: contentUrl); + + if (parts2.Length == 2) + { + switch (parts2[1].ToLower()) + { + case "animation": + attachment.ContentType = AnimationCard.ContentType; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + case "audio": + attachment.ContentType = AudioCard.ContentType; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + case "hero": + attachment.ContentType = HeroCard.ContentType; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + case "receipt": + attachment.ContentType = ReceiptCard.ContentType; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + case "thumbnail": + attachment.ContentType = ThumbnailCard.ContentType; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + case "signin": + attachment.ContentType = SigninCard.ContentType; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + case "video": + attachment.ContentType = VideoCard.ContentType; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + case "adaptivecard": + attachment.ContentType = "application/vnd.microsoft.card.adaptive"; + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: true, data: data).ConfigureAwait(false); + break; + default: + attachment.ContentType = parts2[1].Trim(); + attachment.Content = await ReadAttachmentFile(turnContext, languageGenerator, contentUrl, attachment.ContentType, isCard: false, data: data).ConfigureAwait(false); + break; + } + } + + if (attachment.Content != null && attachment.Content is string && ((string)attachment.Content).StartsWith("data:")) + { + attachment.ContentUrl = (string)attachment.Content; + attachment.Content = null; + } + + if (attachment.Content != null) + { + // if we are sending content, then no need for contentUrl + attachment.ContentUrl = null; + } + + activity.Attachments.Add(attachment); + } + private static int AddJsonAttachment(IMessageActivity activity, string[] lines, int iLine) { StringBuilder sb = new StringBuilder(); diff --git a/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextTemplate.cs b/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextTemplate.cs index 54ecc3fc9..e47b7641b 100644 --- a/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextTemplate.cs +++ b/libraries/Microsoft.Bot.Builder.Dialogs/templating/TextTemplate.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; namespace Microsoft.Bot.Builder.Dialogs { - /// /// Defines an text Template where the template expression is local aka "inline". /// @@ -46,6 +45,5 @@ namespace Microsoft.Bot.Builder.Dialogs { return $"{nameof(TextTemplate)}({this.Template})"; } - } } diff --git a/libraries/Microsoft.Bot.Builder.Expressions/BuiltInFunctions.cs b/libraries/Microsoft.Bot.Builder.Expressions/BuiltInFunctions.cs index 96838b4ad..cb8843a04 100644 --- a/libraries/Microsoft.Bot.Builder.Expressions/BuiltInFunctions.cs +++ b/libraries/Microsoft.Bot.Builder.Expressions/BuiltInFunctions.cs @@ -495,7 +495,6 @@ namespace Microsoft.Bot.Builder.Expressions return (value, error); }; - /// /// walk dialog callstack looking for property /// diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/AdapterExtensions.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/AdapterExtensions.cs index a00517752..e3c872b77 100644 --- a/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/AdapterExtensions.cs +++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/AdapterExtensions.cs @@ -44,6 +44,7 @@ namespace Microsoft.Bot.Builder.Dialogs { botAdapter.UseLanguageGeneration(resourceExplorer, new ResourceMultiLanguageGenerator(defaultLg)); } + return botAdapter; } diff --git a/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/MultiLanguageGenerator.cs b/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/MultiLanguageGenerator.cs index 2da924041..544fd4912 100644 --- a/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/MultiLanguageGenerator.cs +++ b/libraries/Microsoft.Bot.Builder.LanguageGeneration.Renderer/MultiLanguageGenerator.cs @@ -6,7 +6,6 @@ using Microsoft.Bot.Builder.Dialogs; namespace Microsoft.Bot.Builder.LanguageGeneration { - /// /// ILanguageGenerator which uses implements a map of locale->ILanguageGenerator for the locale and has a policy which controls fallback (try en-us -> en -> default) /// diff --git a/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateManager.cs b/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateManager.cs index 535ab5cc3..287e36f3d 100644 --- a/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateManager.cs +++ b/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateManager.cs @@ -38,9 +38,9 @@ namespace Microsoft.Bot.Builder.TemplateManager { if (!this.Renderers.Contains(renderer)) { - this.Renderers.Add(renderer); } + return this; } diff --git a/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateOptions.cs b/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateOptions.cs index 2d975eedf..1cba622bd 100644 --- a/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateOptions.cs +++ b/libraries/Microsoft.Bot.Builder.TemplateManager/TemplateOptions.cs @@ -12,6 +12,7 @@ namespace Microsoft.Bot.Builder.TemplateManager { [JsonProperty(PropertyName = "template")] public string TemplateId { get; set; } + [JsonProperty(PropertyName = "data")] public object Data { get; set; } } diff --git a/libraries/Microsoft.Bot.Builder/FileTranscriptLogger.cs b/libraries/Microsoft.Bot.Builder/FileTranscriptLogger.cs index 2037dbf9b..3b42a3cf5 100644 --- a/libraries/Microsoft.Bot.Builder/FileTranscriptLogger.cs +++ b/libraries/Microsoft.Bot.Builder/FileTranscriptLogger.cs @@ -20,33 +20,10 @@ namespace Microsoft.Bot.Builder /// public class FileTranscriptLogger : ITranscriptStore { - private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings() - { - Formatting = Formatting.Indented, - NullValueHandling = NullValueHandling.Ignore, - }; - private string folder; private bool unitTestMode; private HashSet started = new HashSet(); - private static async Task LoadTranscript(string transcriptFile) - { - if (File.Exists(transcriptFile)) - { - using (var stream = File.OpenRead(transcriptFile)) - { - using (var reader = new StreamReader(stream) as TextReader) - { - var json = await reader.ReadToEndAsync().ConfigureAwait(false); - return JsonConvert.DeserializeObject(json); - } - } - } - - return Array.Empty(); - } - /// /// Initializes a new instance of the class. /// @@ -70,6 +47,29 @@ namespace Microsoft.Bot.Builder this.unitTestMode = unitTestMode; } + private static JsonSerializerSettings jsonSettings = new JsonSerializerSettings() + { + Formatting = Formatting.Indented, + NullValueHandling = NullValueHandling.Ignore, + }; + + private static async Task LoadTranscript(string transcriptFile) + { + if (File.Exists(transcriptFile)) + { + using (var stream = File.OpenRead(transcriptFile)) + { + using (var reader = new StreamReader(stream) as TextReader) + { + var json = await reader.ReadToEndAsync().ConfigureAwait(false); + return JsonConvert.DeserializeObject(json); + } + } + } + + return Array.Empty(); + } + /// /// Log an activity to the transcript. /// @@ -117,7 +117,7 @@ namespace Microsoft.Bot.Builder switch (activity.Type) { case ActivityTypes.MessageDelete: - await messageDelete(activity, transcriptFile).ConfigureAwait(false); + await MessageDelete(activity, transcriptFile).ConfigureAwait(false); return; case ActivityTypes.MessageUpdate: @@ -257,7 +257,7 @@ namespace Microsoft.Bot.Builder } } - private async Task messageDelete(IActivity activity, string transcriptFile) + private async Task MessageDelete(IActivity activity, string transcriptFile) { // load all activities var transcript = await LoadTranscript(transcriptFile).ConfigureAwait(false); diff --git a/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs b/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs index fd6f9ed85..7b33a5d3f 100644 --- a/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs +++ b/tests/Microsoft.Bot.Builder.AI.QnA.Tests/QnAMakerTests.cs @@ -61,7 +61,6 @@ namespace Microsoft.Bot.Builder.AI.QnA.Tests }); } - [TestMethod] public async Task QnAMakerDialog_Answers() { diff --git a/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Generator.cs b/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Generator.cs index d878d77e0..c38e1f2bc 100644 --- a/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Generator.cs +++ b/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Generator.cs @@ -10,6 +10,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests { public string Type; public object Value; + public Comparison(string type, object value) { Type = type; @@ -343,6 +344,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests binaryExpression = Expression.MakeExpression(type, binaryExpression, info.Expression); } } + return binaryExpression; } @@ -364,6 +366,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests break; } } + baseName = mem.Substring(0, i); return int.Parse(mem.Substring(i)); } @@ -407,6 +410,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests } } } + var any = Rand.NextDouble() < 0.5; if (any) { @@ -511,8 +515,8 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests } break; - } + return isNot ? null : new Comparison(comparison.Type, value); } @@ -548,6 +552,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests result[type].Add(binding.Key); } + return result; } @@ -580,6 +585,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests { totalWeight += choice.Weight; } + var selection = Rand.NextDouble() * totalWeight; var soFar = 0.0; var result = default(T); diff --git a/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Tests.cs b/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Tests.cs index a332bac8c..d5997a52f 100644 --- a/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Tests.cs +++ b/tests/Microsoft.Bot.Builder.AI.TriggerTrees.Tests/Tests.cs @@ -104,6 +104,7 @@ namespace Microsoft.Bot.Builder.AI.TriggerTrees.Tests { memory.Add(binding.Key, binding.Value.Value); } + var trigger = tree.AddTrigger(conjunction.Expression, conjunction.Bindings); var matches = tree.Matches(memory); triggers.Add(trigger); diff --git a/tests/Microsoft.Bot.Builder.Azure.Tests/AzureBlobTranscriptStoreTests.cs b/tests/Microsoft.Bot.Builder.Azure.Tests/AzureBlobTranscriptStoreTests.cs index 63e4a749c..9e961d01f 100644 --- a/tests/Microsoft.Bot.Builder.Azure.Tests/AzureBlobTranscriptStoreTests.cs +++ b/tests/Microsoft.Bot.Builder.Azure.Tests/AzureBlobTranscriptStoreTests.cs @@ -27,7 +27,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests [TestCategory("Storage - BlobTranscripts")] public class AzureBlobTranscriptStoreTests : StorageBaseTests { - private const string ConnectionString = @"AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;"; private const string ChannelId = "test"; @@ -125,7 +124,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests Assert.AreEqual(5, loggedActivities.Length); } - } // These tests require Azure Storage Emulator v5.7 @@ -172,7 +170,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests { if (CheckEmulator()) { - for (var i = 0; i < ConversationSpecialIds.Length; i++) { var a = CreateActivity(i, i, ConversationSpecialIds); @@ -191,7 +188,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests { if (CheckEmulator()) { - var cleanChanel = Guid.NewGuid().ToString(); var loggedPagedResult = new PagedResult(); @@ -244,7 +240,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests { if (CheckEmulator()) { - try { var a = CreateActivity(0, 0, LongId); @@ -256,6 +251,7 @@ namespace Microsoft.Bot.Builder.Azure.Tests { return; } + Assert.Fail("Should have thrown "); } } @@ -287,7 +283,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests { if (CheckEmulator()) { - AzureBlobTranscriptStore store = null; await Assert.ThrowsExceptionAsync(async () => @@ -303,7 +298,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests { if (CheckEmulator()) { - var conversation = TestAdapter.CreateConversation(Guid.NewGuid().ToString("n")); TestAdapter adapter = new TestAdapter(conversation) .Use(new TranscriptLoggerMiddleware(TranscriptStore)); @@ -351,7 +345,6 @@ namespace Microsoft.Bot.Builder.Azure.Tests { if (CheckEmulator()) { - var conversation = TestAdapter.CreateConversation(Guid.NewGuid().ToString("n")); TestAdapter adapter = new TestAdapter(conversation) .Use(new TranscriptLoggerMiddleware(TranscriptStore)); diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ActionTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ActionTests.cs index 5d23ca3ec..477c27a79 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ActionTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/ActionTests.cs @@ -272,7 +272,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new SetProperty() @@ -311,7 +310,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new SetProperty() @@ -473,7 +471,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new ChoiceInput() @@ -602,7 +599,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new SetProperty() @@ -912,7 +908,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests new SendActivity("One") { Tags = { "a" } }, new SendActivity("Three") { Tags = { "c" } }, } - }, new OnIntent() { @@ -989,7 +984,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests .StartTestAsync(); } - [TestMethod] public async Task Action_BeginDialog() { @@ -1012,7 +1006,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new IfCondition() @@ -1033,13 +1026,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests } }; - var testDialog = new AdaptiveDialog("planningTest"); testDialog.AutoEndDialog = false; testDialog.Recognizer = new RegexRecognizer() { Intents = new Dictionary() { { "JokeIntent", "joke" } } }; - testDialog.AddEvents(new List() { new OnBeginDialog() @@ -1098,7 +1089,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new IfCondition() @@ -1216,7 +1206,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new TextInput() { Prompt = new ActivityTemplate("Hello, what is your name?"), OutputBinding = "user.name" , Value = "user.name" }, @@ -1284,7 +1273,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new BeginDialog(outer.Id) diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/AdaptiveDialogTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/AdaptiveDialogTests.cs index 4ae95479f..f1c5dc1b5 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/AdaptiveDialogTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/AdaptiveDialogTests.cs @@ -133,7 +133,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests AlwaysPrompt = true, Prompt = new ActivityTemplate("Please add an item to todos."), Property = "dialog.todo" - }, new EditArray(EditArray.ArrayChangeType.Push, "user.todos", "dialog.todo"), new SendActivity() { Activity = new ActivityTemplate("Your todos: {join(user.todos, ',')}") }, @@ -594,7 +593,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new IfCondition() @@ -624,7 +622,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new SendActivity("Why did the chicken cross the road?"), @@ -681,7 +678,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests }; outerDialog.AddDialogs(new List() { innerDialog }); - await CreateFlow(outerDialog) .Send("hi") .AssertReply("Hi, type 'begin' to start a dialog, type 'help' to get help.") diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/DialogContextStateTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/DialogContextStateTests.cs index 3bea14fa6..170bcb748 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/DialogContextStateTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/DialogContextStateTests.cs @@ -20,7 +20,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests public class Bar { public string Name { get; set; } + public int Age { get; set; } + public bool cool { get; set; } } @@ -67,7 +69,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests conversationState: new Dictionary(StringComparer.InvariantCultureIgnoreCase), turnState: new Dictionary(StringComparer.InvariantCultureIgnoreCase)); - // simple value types state.SetValue("UseR.nuM", 15); state.SetValue("uSeR.NuM", 25); @@ -116,7 +117,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests conversationState: new Dictionary(StringComparer.InvariantCultureIgnoreCase), turnState: new Dictionary(StringComparer.InvariantCultureIgnoreCase)); - // complex type paths state.SetValue("UseR.fOo", foo); Assert.IsTrue(state.HasValue("user.foo.SuBname.name"), "should have the value"); @@ -150,7 +150,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests conversationState: new Dictionary(StringComparer.InvariantCultureIgnoreCase), turnState: new Dictionary(StringComparer.InvariantCultureIgnoreCase)); - // complex type paths state.SetValue("user.name", "joe"); state.SetValue("conversation[user.name]", "test"); @@ -174,7 +173,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests conversationState: new Dictionary(StringComparer.InvariantCultureIgnoreCase), turnState: new Dictionary(StringComparer.InvariantCultureIgnoreCase)); - // complex type paths #pragma warning disable CS0168 // The variable 'val' is declared but never used object val; @@ -206,7 +204,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests conversationState: new Dictionary(StringComparer.InvariantCultureIgnoreCase), turnState: new Dictionary(StringComparer.InvariantCultureIgnoreCase)); - // complex type paths state.SetValue("UseR.fOo", foo); Assert.IsTrue(state.HasValue("user.foo"), "should have the value"); @@ -307,7 +304,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new OnBeginDialog() { - Actions = new List() { new SetProperty() @@ -583,6 +579,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests .AssertReply("xyz") .StartTestAsync(); } - } } diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/MiscTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/MiscTests.cs index 3a93d0be5..8c24cd29a 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/MiscTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/MiscTests.cs @@ -84,6 +84,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests { new SendActivity("notcanceling") } + // We do not need to specify an else block here since if user said no, // the control flow will automatically return to the last active step (if any) } @@ -148,7 +149,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests } } } - }; await CreateFlow(testDialog) diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/SettingsStateTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/SettingsStateTests.cs index 16db3544d..71ab9f262 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/SettingsStateTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Adaptive.Tests/SettingsStateTests.cs @@ -75,6 +75,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Tests await dm.OnTurnAsync(turnContext, cancellationToken: cancellationToken).ConfigureAwait(false); }); } - } } diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/EntityRecognizerTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/EntityRecognizerTests.cs index 983784057..4de440999 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/EntityRecognizerTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/EntityRecognizerTests.cs @@ -84,7 +84,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers.Tests Assert.AreEqual(1, results.Where(entity => entity.Type == "datetimeV2.datetime").Count(), "Should have 1 datetime result"); } - [TestMethod] public void TestDimension() { @@ -186,7 +185,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Recognizers.Tests Assert.AreEqual(1, results.Where(entity => entity.Type == "percentage").Count(), "Should have 1 percentage"); } - [TestMethod] public void TestPhoneNumber() { diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/ObjectAssignTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/ObjectAssignTests.cs index 50d1a7815..f9adc67f6 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/ObjectAssignTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/ObjectAssignTests.cs @@ -7,15 +7,20 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition public class Location { public float? Lat { get; set; } + public float? Long { get; set; } } public class Options { public string FirstName { get; set; } + public string LastName { get; set; } + public int? Age { get; set; } + public bool? Bool { get; set; } + public Location Location { get; set; } } @@ -364,6 +369,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition Assert.AreEqual(result.Location.Lat, defaultOptions.Location.Lat); Assert.AreEqual(result.Location.Long, defaultOptions.Location.Long); } - } } diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/TestUtilities.cs b/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/TestUtilities.cs index 93d359a5f..1dafb3068 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/TestUtilities.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Composition.Tests/TestUtilities.cs @@ -59,6 +59,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Composition.Tests if (string.IsNullOrWhiteSpace(value)) value = null; } + return value; } } diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Debugging.Tests/identifierTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Debugging.Tests/identifierTests.cs index 74c42686b..3825488f0 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Debugging.Tests/identifierTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Debugging.Tests/identifierTests.cs @@ -12,7 +12,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging.Tests [TestClass] public sealed class IdentifierTests { - public static IEnumerable Bytes => new[]{ + public static IEnumerable Bytes => new[] { 0ul, 0x7Eul, 0x7Ful, 0x80ul, 0x81ul, 0xFFul, }; diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Declarative.Tests/ResourceExplorerTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Declarative.Tests/ResourceExplorerTests.cs index 8cb53f9fd..4531070b9 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Declarative.Tests/ResourceExplorerTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Declarative.Tests/ResourceExplorerTests.cs @@ -43,7 +43,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Tests Assert.IsNull(dialog, $"GetResource({id}) should return null"); var dialogs = explorer.GetResources("dialog"); Assert.IsFalse(dialogs.Where(d => d.Id == id).Any(), $"getResources({id}) should not return resource"); - } private async Task AssertResourceContents(ResourceExplorer explorer, string id, string contents) @@ -163,7 +162,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Tests } } - [TestMethod] public async Task TestFolderSource_DeleteFiresChanged() { diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Tests/ConfirmPromptLocTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Tests/ConfirmPromptLocTests.cs index 9ff853973..f120963f4 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Tests/ConfirmPromptLocTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Tests/ConfirmPromptLocTests.cs @@ -14,7 +14,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests { public TestContext TestContext { get; set; } - [TestMethod] [DataRow(null, Culture.Dutch, "(1) Ja of (2) Nee", "Ja", "1")] [DataRow(null, Culture.Dutch, "(1) Ja of (2) Nee", "Nee", "0")] diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Tests/DateTimePromptTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Tests/DateTimePromptTests.cs index addea3e2f..a4b820a9f 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Tests/DateTimePromptTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Tests/DateTimePromptTests.cs @@ -14,7 +14,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Microsoft.Bot.Builder.Dialogs.Tests { - [TestClass] public class DateTimePromptTests { diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Tests/DialogManagerTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Tests/DialogManagerTests.cs index d03e6fd67..3c0703a7c 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Tests/DialogManagerTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Tests/DialogManagerTests.cs @@ -69,7 +69,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests [TestMethod] public void DialogManager_UserState_PersistedAcrossTurns() { - } [TestMethod] @@ -106,7 +105,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests var componentDialog = new ComponentDialog(); componentDialog.AddDialog(outerAdaptiveDialog); - await CreateFlow(componentDialog, storage, firstConversationId) .Send("hi") .AssertReply("Hello, what is your name?") @@ -120,7 +118,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests .StartTestAsync(); } - private AdaptiveDialog CreateTestDialog(string property = "user.name") { var adaptiveDialog = new AdaptiveDialog("planningTest"); diff --git a/tests/Microsoft.Bot.Builder.Dialogs.Tests/TextMessageGeneratorTests.cs b/tests/Microsoft.Bot.Builder.Dialogs.Tests/TextMessageGeneratorTests.cs index 217217f6b..179387ca6 100644 --- a/tests/Microsoft.Bot.Builder.Dialogs.Tests/TextMessageGeneratorTests.cs +++ b/tests/Microsoft.Bot.Builder.Dialogs.Tests/TextMessageGeneratorTests.cs @@ -40,12 +40,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests TypeFactory.RegisterAdaptiveTypes(); resourceExplorer = ResourceExplorer.LoadProject(GetProjectFolder()); } + private static string GetProjectFolder() { return AppContext.BaseDirectory.Substring(0, AppContext.BaseDirectory.IndexOf("bin")); } - [ClassCleanup] public static void ClassCleanup() { @@ -61,14 +61,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests private async Task GetTurnContext(string lgFile) { - var context = new TurnContext(new TestAdapter(), new Activity()); var lgText = await resourceExplorer.GetResource(lgFile).ReadTextAsync(); context.TurnState.Add(new TemplateEngineLanguageGenerator(lgText, "test", LanguageGeneratorManager.ResourceResolver(resourceExplorer))); return context; } - [TestMethod] public async Task TestInline() { @@ -198,7 +196,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests Assert.AreEqual("https://docs.microsoft.com/en-us/bot-framework/media/how-it-works/architecture-resize.png", activity.Attachments[0].ContentUrl); } - [TestMethod] public async Task TestLocalImageAttachment() { @@ -217,7 +214,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests Assert.AreEqual(237449, bytes.Length); } - [TestMethod] public async Task TestAdaptiveCard() { @@ -297,7 +293,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests Assert.AreEqual("test", (string)((dynamic)activity.Attachments[1].Content).body[0].text); } - [TestMethod] public async Task TestAttachmentContentType() { @@ -313,6 +308,5 @@ namespace Microsoft.Bot.Builder.Dialogs.Tests Assert.AreEqual("image/png", activity.Attachments[0].ContentType); Assert.AreEqual(data.url.ToString(), activity.Attachments[0].ContentUrl.ToString()); } - } } diff --git a/tests/Microsoft.Bot.Builder.Expressions.Tests/BadExpressionTests.cs b/tests/Microsoft.Bot.Builder.Expressions.Tests/BadExpressionTests.cs index 1cf7f5124..58a6941ee 100644 --- a/tests/Microsoft.Bot.Builder.Expressions.Tests/BadExpressionTests.cs +++ b/tests/Microsoft.Bot.Builder.Expressions.Tests/BadExpressionTests.cs @@ -35,7 +35,6 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("user.lists.{dialog.listName}") }; - [DataTestMethod] [DynamicData(nameof(InvalidExpressions))] [ExpectedException(typeof(Exception))] @@ -52,7 +51,6 @@ namespace Microsoft.Bot.Builder.Expressions.Tests } } - public static IEnumerable BadExpressions => new[] { # region General test diff --git a/tests/Microsoft.Bot.Builder.Expressions.Tests/ExpressionEngineTests.cs b/tests/Microsoft.Bot.Builder.Expressions.Tests/ExpressionEngineTests.cs index ee1d1d003..cecbd1cab 100644 --- a/tests/Microsoft.Bot.Builder.Expressions.Tests/ExpressionEngineTests.cs +++ b/tests/Microsoft.Bot.Builder.Expressions.Tests/ExpressionEngineTests.cs @@ -65,7 +65,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests { "timestampObj", DateTime.Parse("2018-03-15T13:00:00.000Z").ToUniversalTime() }, { "unixTimestamp", 1521118800 }, { "xmlStr", " Gala apple 20 Honeycrisp apple 10 " }, - {"jsonStr", @"{ + { "jsonStr", @"{ 'Stores': [ 'Lambton Quay', 'Willis Street' @@ -241,8 +241,8 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("(1 + 3) / 2", 2), Test("1 * (2 + 3)", 5), Test("(1 + 2) * 3", 9), - Test("(one + two) * bag.three", 9.0, new HashSet {"one", "two", "bag.three" }), - Test("(one + two) * bag.set.four", 12.0, new HashSet {"one", "two", "bag.set.four" } ), + Test("(one + two) * bag.three", 9.0, new HashSet { "one", "two", "bag.three" }), + Test("(one + two) * bag.set.four", 12.0, new HashSet { "one", "two", "bag.set.four" } ), Test("2^2", 4.0), Test("3^2^2", 81.0), @@ -254,8 +254,8 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("!exists(xione) || !!exists(two)", true), Test("(1 + 2) == (4 - 1)", true), Test("!!exists(one) == !!exists(one)", true), - Test("!(one == 1.0)", false, new HashSet {"one" }), - Test("!!(one == 1.0)", true, new HashSet {"one" }), + Test("!(one == 1.0)", false, new HashSet { "one" }), + Test("!!(one == 1.0)", true, new HashSet { "one" }), Test("!(one == 1.0) || !!(two == 2.0)", true, oneTwo), Test("!true", false), Test("!!true", true), @@ -304,7 +304,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("replace('hello', 'l', 'k')","hekko"), Test("replace('hello', 'L', 'k')","hello"), Test("replaceIgnoreCase('hello', 'L', 'k')","hekko"), - Test("split('hello','e')",new string[]{ "h","llo"}), + Test("split('hello','e')",new string[] { "h","llo"}), Test("substring('hello', 0, 5)", "hello"), Test("substring('hello', 0, 3)", "hel"), Test("substring('hello', 3)", "lo"), @@ -359,7 +359,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("less(2, 2)", false), Test("less(one, two)", true), Test("less(one, two)", true, oneTwo), - Test("lessOrEquals(one, one)", true, new HashSet{"one" }), + Test("lessOrEquals(one, one)", true, new HashSet { "one" }), Test("lessOrEquals(one, two)", true, oneTwo), Test("lessOrEquals(one, one)", true), Test("lessOrEquals(one, two)", true), @@ -384,8 +384,8 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("not(one != null)", false), Test("not(not(one != null))", true), Test("not(false)", true), - Test("not(one == 1.0)", false, new HashSet {"one" }), - Test("not(not(one == 1.0))", true, new HashSet {"one" }), + Test("not(one == 1.0)", false, new HashSet { "one" }), + Test("not(not(one == 1.0))", true, new HashSet { "one" }), Test("not(false)", true), Test("and(one > 0.5, two < 2.5)", true, oneTwo), Test("and(float(5.5), float(0.0))", true), @@ -415,9 +415,9 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("bool(hello * 5)", false), Test("bool('false')", true), Test("bool('hi')", true), - Test("createArray('h', 'e', 'l', 'l', 'o')", new List{"h", "e", "l", "l", "o" }), - Test("createArray(1, bool(0), string(bool(1)), float('10'))", new List{1, true, "true", 10.0f }), - Test("array('hello')",new List{ "hello" }), + Test("createArray('h', 'e', 'l', 'l', 'o')", new List { "h", "e", "l", "l", "o" }), + Test("createArray(1, bool(0), string(bool(1)), float('10'))", new List { 1, true, "true", 10.0f }), + Test("array('hello')",new List { "hello" }), Test("binary(hello)", "0110100001100101011011000110110001101111"), Test("length(binary(hello))", 40), Test("base64(hello)", "aGVsbG8="), @@ -455,8 +455,8 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("mod(5,2)", 1), Test("rand(1, 2)", 1), Test("rand(2, 3)", 2), - Test("range(1,4)",new[]{1,2,3,4}), - Test("range(-1,6)",new[]{-1,0,1,2,3,4}), + Test("range(1,4)",new[] { 1,2,3,4}), + Test("range(-1,6)",new[] { -1,0,1,2,3,4}), # endregion # region Date and time function test @@ -553,13 +553,13 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("join(createArray('a', 'b', 'c'), ',', ' and ')", "a,b and c"), Test("join(createArray('a', 'b'), ',', ' and ')", "a and b"), Test("join(foreach(items, item, item), ',')", "zero,one,two"), - Test("join(foreach(nestedItems, i, i.x + first(nestedItems).x), ',')", "2,3,4", new HashSet{ "nestedItems"}), - Test("join(foreach(items, item, concat(item, string(count(items)))), ',')", "zero3,one3,two3", new HashSet{ "items"}), + Test("join(foreach(nestedItems, i, i.x + first(nestedItems).x), ',')", "2,3,4", new HashSet { "nestedItems"}), + Test("join(foreach(items, item, concat(item, string(count(items)))), ',')", "zero3,one3,two3", new HashSet { "items"}), Test("join(select(items, item, item), ',')", "zero,one,two"), - Test("join(select(nestedItems, i, i.x + first(nestedItems).x), ',')", "2,3,4", new HashSet{ "nestedItems"}), - Test("join(select(items, item, concat(item, string(count(items)))), ',')", "zero3,one3,two3", new HashSet{ "items"}), + Test("join(select(nestedItems, i, i.x + first(nestedItems).x), ',')", "2,3,4", new HashSet { "nestedItems"}), + Test("join(select(items, item, concat(item, string(count(items)))), ',')", "zero3,one3,two3", new HashSet { "items"}), Test("join(where(items, item, item == 'two'), ',')", "two"), - Test("join(foreach(where(nestedItems, item, item.x > 1), result, result.x), ',')", "2,3", new HashSet{ "nestedItems"}), + Test("join(foreach(where(nestedItems, item, item.x > 1), result, result.x), ',')", "2,3", new HashSet { "nestedItems"}), Test("last(items)", "two"), Test("last('hello')", "o"), Test("last(createArray(0, 1, 2))", 2), @@ -568,9 +568,9 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("count(union(createArray('a', 'b'), createArray('b', 'c'), createArray('b', 'd')))", 4), Test("count(intersection(createArray('a', 'b')))", 2), Test("count(intersection(createArray('a', 'b'), createArray('b', 'c'), createArray('b', 'd')))", 1), - Test("skip(createArray('H','e','l','l','0'),2)", new List{"l", "l", "0"}), - Test("take(createArray('H','e','l','l','0'),2)", new List{"H", "e"}), - Test("subArray(createArray('H','e','l','l','o'),2,5)", new List{"l", "l", "o"}), + Test("skip(createArray('H','e','l','l','0'),2)", new List { "l", "l", "0"}), + Test("take(createArray('H','e','l','l','0'),2)", new List { "H", "e"}), + Test("subArray(createArray('H','e','l','l','o'),2,5)", new List { "l", "l", "o"}), Test("count(newGuid())", 36), Test("indexOf(newGuid(), '-')", 8), Test("indexOf(hello, '-')", -1), @@ -587,31 +587,31 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Test("xPath(xmlStr,'/produce/item/name')", new[] { "Gala", "Honeycrisp"}), Test("xPath(xmlStr,'sum(/produce/item/count)')", 30), Test("jPath(jsonStr,'Manufacturers[0].Products[0].Price')", 50), - Test("jPath(jsonStr,'$..Products[?(@.Price >= 50)].Name')", new[] {"Anvil", "Elbow Grease" }), + Test("jPath(jsonStr,'$..Products[?(@.Price >= 50)].Name')", new[] { "Anvil", "Elbow Grease" }), # endregion # region Short Hand Expression - Test("@city == 'Bellevue'", false, new HashSet {"turn.recognized.entities.city"}), - Test("@city", "Seattle", new HashSet {"turn.recognized.entities.city"}), - Test("@city == 'Seattle'", true, new HashSet {"turn.recognized.entities.city"}), - Test("@@city[0]","Seattle", new HashSet {"turn.recognized.entities.city[0]"}), + Test("@city == 'Bellevue'", false, new HashSet { "turn.recognized.entities.city"}), + Test("@city", "Seattle", new HashSet { "turn.recognized.entities.city"}), + Test("@city == 'Seattle'", true, new HashSet { "turn.recognized.entities.city"}), + Test("@@city[0]","Seattle", new HashSet { "turn.recognized.entities.city[0]"}), Test("count(@@city)", 1), Test("count(@@city) == 1", true), - Test("@ordinal", "1", new HashSet {"turn.recognized.entities.ordinal"}), - Test("@@ordinal[1]", "2", new HashSet {"turn.recognized.entities.ordinal[1]"}), - Test("@['city']", "Seattle", new HashSet {"turn.recognized.entities.city"}), - Test("@[concat('cit', 'y')]", "Seattle", new HashSet {"turn.recognized.entities"}), - Test("@[concat(cit, y)]", "Seattle", new HashSet {"turn.recognized.entities", "cit", "y"}), - Test("#BookFlight == 'BookFlight'", true, new HashSet {"turn.recognized.intents.BookFlight"}), - Test("#BookHotel[1].Where", "Kirkland", new HashSet {"turn.recognized.intents.BookHotel[1].Where"}), - Test("exists(#BookFlight)", true, new HashSet {"turn.recognized.intents.BookFlight"}), + Test("@ordinal", "1", new HashSet { "turn.recognized.entities.ordinal"}), + Test("@@ordinal[1]", "2", new HashSet { "turn.recognized.entities.ordinal[1]"}), + Test("@['city']", "Seattle", new HashSet { "turn.recognized.entities.city"}), + Test("@[concat('cit', 'y')]", "Seattle", new HashSet { "turn.recognized.entities"}), + Test("@[concat(cit, y)]", "Seattle", new HashSet { "turn.recognized.entities", "cit", "y"}), + Test("#BookFlight == 'BookFlight'", true, new HashSet { "turn.recognized.intents.BookFlight"}), + Test("#BookHotel[1].Where", "Kirkland", new HashSet { "turn.recognized.intents.BookHotel[1].Where"}), + Test("exists(#BookFlight)", true, new HashSet { "turn.recognized.intents.BookFlight"}), Test("dialog.title", "Dialog Title"), Test("dialog.subTitle", "Dialog Sub Title"), - Test("~xxx", "instance", new HashSet {"dialog.instance.xxx"}), - Test("~['yyy'].instanceY", "instanceY", new HashSet {"dialog.instance.yyy.instanceY"}), - Test("%xxx", "options", new HashSet {"dialog.options.xxx"}), - Test("%['xxx']", "options", new HashSet {"dialog.options.xxx"}), - Test("%yyy[1]", "optionY2", new HashSet {"dialog.options.yyy[1]"}), + Test("~xxx", "instance", new HashSet { "dialog.instance.xxx"}), + Test("~['yyy'].instanceY", "instanceY", new HashSet { "dialog.instance.yyy.instanceY"}), + Test("%xxx", "options", new HashSet { "dialog.options.xxx"}), + Test("%['xxx']", "options", new HashSet { "dialog.options.xxx"}), + Test("%yyy[1]", "optionY2", new HashSet { "dialog.options.yyy[1]"}), Test("dialog.x", 3), Test("dialog.y", null), Test("dialog.z", null), @@ -627,7 +627,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests #region Memory access Test("getProperty(bag, concat('na','me'))","mybag"), Test("items[2]", "two", new HashSet { "items[2]" }), - Test("bag.list[bag.index - 2]", "blue", new HashSet {"bag.list", "bag.index" }), + Test("bag.list[bag.index - 2]", "blue", new HashSet { "bag.list", "bag.index" }), Test("items[nestedItems[1].x]", "two", new HashSet { "items","nestedItems[1].x" }), Test("bag['name']","mybag"), Test("bag[substring(concat('na','me','more'), 0, length('name'))]","mybag"), @@ -733,6 +733,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests Assert.IsTrue(Convert.ToSingle(actual) == Convert.ToSingle(expected)); } } + // Compare two lists else if (expected is IList expectedList && actual is IList actualList) diff --git a/tests/Microsoft.Bot.Builder.Expressions.Tests/LRUCacheTest.cs b/tests/Microsoft.Bot.Builder.Expressions.Tests/LRUCacheTest.cs index 324931d31..b58c0cafa 100644 --- a/tests/Microsoft.Bot.Builder.Expressions.Tests/LRUCacheTest.cs +++ b/tests/Microsoft.Bot.Builder.Expressions.Tests/LRUCacheTest.cs @@ -55,7 +55,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests var fib9999 = 1242044891; var fib100000 = 2132534333; var maxIdx = 10000; - for (int i = 2; i <= maxIdx; i++){ + for (int i = 2; i <= maxIdx; i++) { cache.TryGet(i - 2, out var prev2); cache.TryGet(i - 1, out var prev1); cache.Set(i, prev1 + prev2); @@ -112,6 +112,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests { tasks.Add(Task.Run(() => storeElement(cache, numOfOps, i))); } + await Task.WhenAll(tasks); for (var i = numOfOps - numOfThreads; i < numOfOps; i++) diff --git a/tests/Microsoft.Bot.Builder.Expressions.Tests/RewriteTests.cs b/tests/Microsoft.Bot.Builder.Expressions.Tests/RewriteTests.cs index d43605299..b6c0aca30 100644 --- a/tests/Microsoft.Bot.Builder.Expressions.Tests/RewriteTests.cs +++ b/tests/Microsoft.Bot.Builder.Expressions.Tests/RewriteTests.cs @@ -52,6 +52,7 @@ namespace Microsoft.Bot.Builder.Expressions.Tests { eval = BuiltInFunctions.Lookup(type); } + return eval; } diff --git a/tests/Microsoft.Bot.Builder.LanguageGeneration.Renderer.Tests/LGGeneratorTests.cs b/tests/Microsoft.Bot.Builder.LanguageGeneration.Renderer.Tests/LGGeneratorTests.cs index 0d3896f6d..53a4f8e5c 100644 --- a/tests/Microsoft.Bot.Builder.LanguageGeneration.Renderer.Tests/LGGeneratorTests.cs +++ b/tests/Microsoft.Bot.Builder.LanguageGeneration.Renderer.Tests/LGGeneratorTests.cs @@ -63,6 +63,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests { context.TurnState.Add(generator); } + return context; } @@ -75,7 +76,6 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests await lg.Generate(context, "[tesdfdfsst]", null); } - [TestMethod] public async Task TestImport() { diff --git a/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineTest.cs b/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineTest.cs index 3b12fbfe3..c64b69c2a 100644 --- a/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineTest.cs +++ b/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineTest.cs @@ -20,7 +20,6 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests return Path.Combine(AppContext.BaseDirectory, "Examples", fileName); } - [TestMethod] public void TestBasic() { @@ -137,12 +136,10 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests } }; - //var alarmStrs = alarms.Select(x => engine.EvaluateTemplate("ShowAlarm", new { alarm = x })).ToList() ; //var evaled = engine.EvaluateTemplate("ShowAlarms", new { alarms = alarmStrs }); //Assert.AreEqual("You have 2 alarms, 7 am at tomorrow and 8 pm at tomorrow", evaled); - var evaled = engine.EvaluateTemplate("ShowAlarmsWithForeach", new { alarms = alarms }); Assert.AreEqual("You have 2 alarms, 7 am at tomorrow and 8 pm at tomorrow", evaled); @@ -154,7 +151,6 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests //var evaled = engine.EvaluateTemplate("ShowAlarmsWithMemberHumanize", new { alarms = alarms }); //Assert.AreEqual("You have 2 alarms, 7 am at tomorrow and 8 pm at tomorrow", evaled); - } [TestMethod] @@ -227,7 +223,6 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests FirstName = "D", LastName = "L" } - }), "Hi DL You don't have any tasks."); Assert.AreEqual(emptyEngine.Evaluate("Hi {name.FirstName}{name.LastName} [RecentTasks]", new @@ -238,10 +233,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests LastName = "L" }, recentTasks = new[] { "task1" } - - }), "Hi DL Your most recent task is task1. You can let me know if you want to add or complete a task."); - } [TestMethod] @@ -394,8 +386,6 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests } } - - [TestMethod] public void TestMultipleLgFiles() { diff --git a/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineThrowExceptionTest.cs b/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineThrowExceptionTest.cs index 5413150f7..e83dde7e1 100644 --- a/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineThrowExceptionTest.cs +++ b/tests/Microsoft.Bot.Builder.LanguageGeneration.Tests/TemplateEngineThrowExceptionTest.cs @@ -21,6 +21,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests } public static object[] Test(string input) => new object[] { input }; + public static object[] TestTemplate(string input, string templateName) => new object[] { input, templateName }; public static IEnumerable StaticCheckExceptionData => new[] @@ -64,7 +65,6 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests TestTemplate("LoopDetected.lg", "NotExistTemplate"), }; - [DataTestMethod] [DynamicData(nameof(StaticCheckExceptionData))] public void ThrowExceptionTest(string input) @@ -113,6 +113,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests isFail = true; errorMessage = "error occurs when parsing file"; } + if (!isFail) { try diff --git a/tests/Microsoft.Bot.Builder.TemplateManager/TemplateManagerTests.cs b/tests/Microsoft.Bot.Builder.TemplateManager/TemplateManagerTests.cs index 49c723c4d..dcc53a581 100644 --- a/tests/Microsoft.Bot.Builder.TemplateManager/TemplateManagerTests.cs +++ b/tests/Microsoft.Bot.Builder.TemplateManager/TemplateManagerTests.cs @@ -110,7 +110,6 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests [TestMethod] public async Task TemplateManager_defaultlookup() { - TestAdapter adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())); @@ -131,7 +130,6 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests [TestMethod] public async Task TemplateManager_DataDefined() { - TestAdapter adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())); @@ -153,11 +151,9 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests .StartTestAsync(); } - [TestMethod] public async Task TemplateManager_enLookup() { - TestAdapter adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())); @@ -179,7 +175,6 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests [TestMethod] public async Task TemplateManager_frLookup() { - TestAdapter adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())); @@ -201,7 +196,6 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests [TestMethod] public async Task TemplateManager_override() { - TestAdapter adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())); @@ -223,7 +217,6 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests [TestMethod] public async Task TemplateManager_useTemplateEngine() { - TestAdapter adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())); @@ -244,7 +237,6 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests [TestMethod] public async Task TemplateManagerMiddleware_Declarative() { - TestAdapter adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)) .Use(new TranscriptLoggerMiddleware(new FileTranscriptLogger())) .Use(new TemplateManagerMiddleware() @@ -256,7 +248,6 @@ namespace Microsoft.Bot.Builder.TemplateManager.Tests } }); - await new TestFlow(adapter, async (context, cancellationToken) => { var templateId = context.Activity.AsMessageActivity().Text.Trim(); diff --git a/tests/Microsoft.Bot.Builder.TestBot.Json/CustomSteps/JavascriptStep.cs b/tests/Microsoft.Bot.Builder.TestBot.Json/CustomSteps/JavascriptStep.cs index 40406ef7c..535f93da3 100644 --- a/tests/Microsoft.Bot.Builder.TestBot.Json/CustomSteps/JavascriptStep.cs +++ b/tests/Microsoft.Bot.Builder.TestBot.Json/CustomSteps/JavascriptStep.cs @@ -67,6 +67,7 @@ namespace Microsoft.Bot.Builder.TestBot.Json payload.state.Turn = response.state.turn; return dc.EndDialogAsync((object)response.result, cancellationToken: cancellationToken); } + return dc.EndDialogAsync(cancellationToken: cancellationToken); } @@ -103,7 +104,5 @@ namespace Microsoft.Bot.Builder.TestBot.Json scriptEngine.Evaluate(sb.ToString()); } - - } } diff --git a/tests/Microsoft.Bot.Builder.TestBot.Json/TestBot.cs b/tests/Microsoft.Bot.Builder.TestBot.Json/TestBot.cs index 6c0f55c9c..c9335730f 100644 --- a/tests/Microsoft.Bot.Builder.TestBot.Json/TestBot.cs +++ b/tests/Microsoft.Bot.Builder.TestBot.Json/TestBot.cs @@ -45,7 +45,6 @@ namespace Microsoft.Bot.Builder.TestBot.Json LoadDialogs(); } - private void LoadDialogs() { System.Diagnostics.Trace.TraceInformation("Loading resources..."); @@ -75,6 +74,7 @@ namespace Microsoft.Bot.Builder.TestBot.Json var dialog = DeclarativeTypeLoader.Load(resource, this.resourceExplorer, DebugSupport.SourceRegistry); handleChoice.Cases.Add(new Case($"{name}", new List() { dialog })); } + choiceInput.Style = ListStyle.Auto; rootDialog.Events.Add(new OnBeginDialog() { diff --git a/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotAccessors.cs b/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotAccessors.cs index 7ecb199bc..4997f57fc 100644 --- a/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotAccessors.cs +++ b/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotAccessors.cs @@ -12,7 +12,7 @@ namespace Microsoft.Bot.Builder.TestBot.Json public ConversationState ConversationState { get; set; } - public UserState UserState{ get; set; } + public UserState UserState { get; set; } public SemaphoreSlim SemaphoreSlim { get; } = new SemaphoreSlim(1, 1); } diff --git a/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotHttpAdapter.cs b/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotHttpAdapter.cs index 2f41c5a04..b27d89794 100644 --- a/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotHttpAdapter.cs +++ b/tests/Microsoft.Bot.Builder.TestBot.Json/TestBotHttpAdapter.cs @@ -50,7 +50,6 @@ namespace Microsoft.Bot.Builder.TestBot.Json { try { - // Delete the conversationState for the current conversation to prevent the // bot from getting stuck in a error-loop caused by being in a bad state. // ConversationState should be thought of as similar to "cookie-state" in a Web pages. diff --git a/tests/Microsoft.Bot.Builder.Tests/BotAdapterBracketingTest.cs b/tests/Microsoft.Bot.Builder.Tests/BotAdapterBracketingTest.cs index 6273f266c..caa8adb94 100644 --- a/tests/Microsoft.Bot.Builder.Tests/BotAdapterBracketingTest.cs +++ b/tests/Microsoft.Bot.Builder.Tests/BotAdapterBracketingTest.cs @@ -13,7 +13,6 @@ namespace Microsoft.Bot.Builder.Tests [TestCategory("Middleware")] public class BotAdapterBracketingTest { - public TestContext TestContext { get; set; } /// diff --git a/tests/Microsoft.Bot.Builder.Tests/BotStateTests.cs b/tests/Microsoft.Bot.Builder.Tests/BotStateTests.cs index a0bef7b53..1613dd8cf 100644 --- a/tests/Microsoft.Bot.Builder.Tests/BotStateTests.cs +++ b/tests/Microsoft.Bot.Builder.Tests/BotStateTests.cs @@ -355,7 +355,6 @@ namespace Microsoft.Bot.Builder.Tests [TestMethod] public async Task State_DoNOTRememberContextState() { - var adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName)); await new TestFlow(adapter, (context, cancellationToken) => diff --git a/tests/Microsoft.Bot.Builder.Tests/Transcript_MiddlewareTests.cs b/tests/Microsoft.Bot.Builder.Tests/Transcript_MiddlewareTests.cs index 7051a4c7c..7b49e089b 100644 --- a/tests/Microsoft.Bot.Builder.Tests/Transcript_MiddlewareTests.cs +++ b/tests/Microsoft.Bot.Builder.Tests/Transcript_MiddlewareTests.cs @@ -46,7 +46,6 @@ namespace Microsoft.Bot.Builder.Tests { var transcriptStore = new MemoryTranscriptStore(); await _TestDateLogUpdateActivitiesTest(transcriptStore); - } [TestMethod] @@ -79,7 +78,6 @@ namespace Microsoft.Bot.Builder.Tests { var transcriptStore = GetFileTranscriptLogger(); await _TestDateLogUpdateActivitiesTest(transcriptStore); - } private FileTranscriptLogger GetFileTranscriptLogger() @@ -92,6 +90,7 @@ namespace Microsoft.Bot.Builder.Tests foreach (var file in Directory.GetFiles(path, "*.transcript", new EnumerationOptions() { RecurseSubdirectories = true })) File.Delete(file); } + var transcriptStore = new FileTranscriptLogger(path); return transcriptStore; } @@ -138,7 +137,6 @@ namespace Microsoft.Bot.Builder.Tests } } - public static async Task _LogUpdateActivitiesTest(ITranscriptStore transcriptStore) { var conversation = TestAdapter.CreateConversation(Guid.NewGuid().ToString("n")); @@ -227,7 +225,6 @@ namespace Microsoft.Bot.Builder.Tests Assert.AreEqual(0, pagedResult.Items.Length); } - private static async Task _LogDeleteActivitesTest(ITranscriptStore transcriptStore) { var conversation = TestAdapter.CreateConversation(Guid.NewGuid().ToString("n"));