Merge branch '4.next' into wportnoy/FixIdentifierLeak
This commit is contained in:
Коммит
b15822a9b2
|
@ -101,13 +101,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Debugging
|
|||
|
||||
private readonly Task task;
|
||||
|
||||
public DebugAdapter(IDataModel model, Source.IRegistry registry, IBreakpoints breakpoints, ILogger logger)
|
||||
public DebugAdapter(int port, IDataModel model, Source.IRegistry registry, IBreakpoints breakpoints, ILogger logger)
|
||||
: base(logger)
|
||||
{
|
||||
this.model = model ?? throw new ArgumentNullException(nameof(model));
|
||||
this.registry = registry ?? throw new ArgumentNullException(nameof(registry));
|
||||
this.breakpoints = breakpoints ?? throw new ArgumentNullException(nameof(breakpoints));
|
||||
this.task = ListenAsync(new IPEndPoint(IPAddress.Any, port: 4712), cancellationToken.Token);
|
||||
this.task = ListenAsync(new IPEndPoint(IPAddress.Any, port: port), cancellationToken.Token);
|
||||
//threads.Add(new BotThreadModel());
|
||||
}
|
||||
|
||||
public async Task DisposeAsync()
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"comments": {
|
||||
"lineComment": "//",
|
||||
"blockComment": [ "/*", "*/" ]
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
{
|
||||
"open": "{",
|
||||
"close": "}",
|
||||
"notIn": [ "string" ]
|
||||
},
|
||||
{ "open": "[", "close": "]", "notIn": ["string"] },
|
||||
{ "open": "(", "close": ")", "notIn": ["string"] },
|
||||
{ "open": "'", "close": "'", "notIn": ["string"] },
|
||||
{ "open": "/*", "close": "*/", "notIn": ["string"] },
|
||||
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }
|
||||
]
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
"keywords": [ "debuggers", "bot" ],
|
||||
"icon": "icon.png",
|
||||
"preview": true,
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.5",
|
||||
"publisher": "Microsoft",
|
||||
"license": "SEE LICENSE file",
|
||||
"engines": {
|
||||
|
@ -17,34 +17,22 @@
|
|||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "dialog",
|
||||
"aliases": [
|
||||
"dialog",
|
||||
"DIALOG"
|
||||
],
|
||||
"id": "json",
|
||||
"extensions": [
|
||||
".dialog"
|
||||
],
|
||||
"configuration": "./language-configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "dialog",
|
||||
"scopeName": "source.json",
|
||||
"path": "./syntaxes/JSON.tmLanguage.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
"debuggers": [
|
||||
{
|
||||
"type": "dialog",
|
||||
"type": "json",
|
||||
"label": "Bot Framework Dialog Debugger",
|
||||
"languages": [
|
||||
"dialog"
|
||||
"json"
|
||||
],
|
||||
"initialConfigurations": [
|
||||
{
|
||||
"type": "dialog",
|
||||
"type": "json",
|
||||
"request": "attach",
|
||||
"name": "Attach to Dialog",
|
||||
"debugServer": 4712
|
||||
|
@ -54,7 +42,7 @@
|
|||
],
|
||||
"breakpoints": [
|
||||
{
|
||||
"language": "dialog"
|
||||
"language": "json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,213 +0,0 @@
|
|||
{
|
||||
"information_for_contributors": [
|
||||
"This file has been converted from https://github.com/Microsoft/vscode-JSON.tmLanguage/blob/master/JSON.tmLanguage",
|
||||
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
|
||||
"Once accepted there, we are happy to receive an update request."
|
||||
],
|
||||
"version": "https://github.com/Microsoft/vscode-JSON.tmLanguage/commit/9bd83f1c252b375e957203f21793316203f61f70",
|
||||
"name": "JSON (Javascript Next)",
|
||||
"scopeName": "source.json",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#value"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"array": {
|
||||
"begin": "\\[",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.array.begin.json"
|
||||
}
|
||||
},
|
||||
"end": "\\]",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.array.end.json"
|
||||
}
|
||||
},
|
||||
"name": "meta.structure.array.json",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#value"
|
||||
},
|
||||
{
|
||||
"match": ",",
|
||||
"name": "punctuation.separator.array.json"
|
||||
},
|
||||
{
|
||||
"match": "[^\\s\\]]",
|
||||
"name": "invalid.illegal.expected-array-separator.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"comments": {
|
||||
"patterns": [
|
||||
{
|
||||
"begin": "/\\*\\*(?!/)",
|
||||
"captures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.comment.json"
|
||||
}
|
||||
},
|
||||
"end": "\\*/",
|
||||
"name": "comment.block.documentation.json"
|
||||
},
|
||||
{
|
||||
"begin": "/\\*",
|
||||
"captures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.comment.json"
|
||||
}
|
||||
},
|
||||
"end": "\\*/",
|
||||
"name": "comment.block.json"
|
||||
},
|
||||
{
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "punctuation.definition.comment.json"
|
||||
}
|
||||
},
|
||||
"match": "(//).*$\\n?",
|
||||
"name": "comment.line.double-slash.js"
|
||||
}
|
||||
]
|
||||
},
|
||||
"constant": {
|
||||
"match": "\\b(?:true|false|null)\\b",
|
||||
"name": "constant.language.json"
|
||||
},
|
||||
"number": {
|
||||
"match": "(?x) # turn on extended mode\n -? # an optional minus\n (?:\n 0 # a zero\n | # ...or...\n [1-9] # a 1-9 character\n \\d* # followed by zero or more digits\n )\n (?:\n (?:\n \\. # a period\n \\d+ # followed by one or more digits\n )?\n (?:\n [eE] # an e character\n [+-]? # followed by an option +/-\n \\d+ # followed by one or more digits\n )? # make exponent optional\n )? # make decimal portion optional",
|
||||
"name": "constant.numeric.json"
|
||||
},
|
||||
"object": {
|
||||
"begin": "\\{",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.dictionary.begin.json"
|
||||
}
|
||||
},
|
||||
"end": "\\}",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.dictionary.end.json"
|
||||
}
|
||||
},
|
||||
"name": "meta.structure.dictionary.json",
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "the JSON object key",
|
||||
"include": "#objectkey"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
},
|
||||
{
|
||||
"begin": ":",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.separator.dictionary.key-value.json"
|
||||
}
|
||||
},
|
||||
"end": "(,)|(?=\\})",
|
||||
"endCaptures": {
|
||||
"1": {
|
||||
"name": "punctuation.separator.dictionary.pair.json"
|
||||
}
|
||||
},
|
||||
"name": "meta.structure.dictionary.value.json",
|
||||
"patterns": [
|
||||
{
|
||||
"comment": "the JSON object value",
|
||||
"include": "#value"
|
||||
},
|
||||
{
|
||||
"match": "[^\\s,]",
|
||||
"name": "invalid.illegal.expected-dictionary-separator.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"match": "[^\\s\\}]",
|
||||
"name": "invalid.illegal.expected-dictionary-separator.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"string": {
|
||||
"begin": "\"",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.string.begin.json"
|
||||
}
|
||||
},
|
||||
"end": "\"",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.string.end.json"
|
||||
}
|
||||
},
|
||||
"name": "string.quoted.double.json",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#stringcontent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"objectkey": {
|
||||
"begin": "\"",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.support.type.property-name.begin.json"
|
||||
}
|
||||
},
|
||||
"end": "\"",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.support.type.property-name.end.json"
|
||||
}
|
||||
},
|
||||
"name": "string.json support.type.property-name.json",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#stringcontent"
|
||||
}
|
||||
]
|
||||
},
|
||||
"stringcontent": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "(?x) # turn on extended mode\n \\\\ # a literal backslash\n (?: # ...followed by...\n [\"\\\\/bfnrt] # one of these characters\n | # ...or...\n u # a u\n [0-9a-fA-F]{4}) # and four hex digits",
|
||||
"name": "constant.character.escape.json"
|
||||
},
|
||||
{
|
||||
"match": "\\\\.",
|
||||
"name": "invalid.illegal.unrecognized-string-escape.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"value": {
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#constant"
|
||||
},
|
||||
{
|
||||
"include": "#number"
|
||||
},
|
||||
{
|
||||
"include": "#string"
|
||||
},
|
||||
{
|
||||
"include": "#array"
|
||||
},
|
||||
{
|
||||
"include": "#object"
|
||||
},
|
||||
{
|
||||
"include": "#comments"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,11 +31,11 @@
|
|||
"processId": "${command:pickProcess}"
|
||||
},
|
||||
{
|
||||
"type": "dialog",
|
||||
"type": "json",
|
||||
"request": "attach",
|
||||
"trace": false,
|
||||
"name": "Attach to Dialog",
|
||||
"debugServer": 4712,
|
||||
"name": "Attach Bot",
|
||||
"debugServer": 9999
|
||||
}
|
||||
]
|
||||
}
|
|
@ -9,11 +9,17 @@
|
|||
"endpoint": "http://localhost:54082/api/messages",
|
||||
"id": "98fd9150-a278-11e8-90fe-f92f88ed2f78",
|
||||
"name": "http://localhost:54082/api/messages"
|
||||
},
|
||||
{
|
||||
"type": "endpoint",
|
||||
"endpoint": "http://localhost:54084/api/messages",
|
||||
"name": "http://localhost:54084/api/messages",
|
||||
"id": "189"
|
||||
}
|
||||
],
|
||||
"padlock": "",
|
||||
"version": "2.0",
|
||||
"path": "C:\\source\\GitHub\\botbuilder-dotnet\\samples\\Microsoft.Bot.Builder.TestBot.Json\\BotBuilderTestBot.bot",
|
||||
"overrides": null,
|
||||
"path": "C:\\source\\GitHub\\botbuilder-dotnet\\samples\\Microsoft.Bot.Builder.TestBot.Json\\BotBuilderTestBot.bot",
|
||||
"secretKey": ""
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<PackageReference Include="Jurassic" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Microsoft.Bot.Builder.TestBot.Json
|
||||
{
|
||||
|
@ -15,7 +16,14 @@ namespace Microsoft.Bot.Builder.TestBot.Json
|
|||
|
||||
public static IWebHost BuildWebHost(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
{
|
||||
var env = hostingContext.HostingEnvironment;
|
||||
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
||||
config.AddEnvironmentVariables();
|
||||
config.AddCommandLine(args);
|
||||
}).UseStartup<Startup>()
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "dialog",
|
||||
"type": "json",
|
||||
"request": "attach",
|
||||
"name": "Attach to Dialog",
|
||||
"debugServer": 4712
|
||||
|
|
|
@ -22,22 +22,16 @@ using Microsoft.Bot.Connector.Authentication;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging.Debug;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.Bot.Builder.TestBot.Json
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment env)
|
||||
public Startup(IHostingEnvironment env, IConfiguration configuration)
|
||||
{
|
||||
HostingEnvironment = env;
|
||||
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(env.ContentRootPath)
|
||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
Configuration = builder.Build();
|
||||
this.HostingEnvironment = env;
|
||||
this.Configuration = configuration;
|
||||
|
||||
// set the configuration for types
|
||||
TypeFactory.Configuration = this.Configuration;
|
||||
|
@ -72,7 +66,10 @@ namespace Microsoft.Bot.Builder.TestBot.Json
|
|||
// by setting the source registry all dialogs will register themselves to be debugged as execution flows
|
||||
DebugSupport.SourceRegistry = sourceMap;
|
||||
var model = new DataModel(Coercion.Instance);
|
||||
debugAdapter = new DebugAdapter(model, sourceMap, sourceMap, new DebugLogger(nameof(DebugAdapter)));
|
||||
var port = Configuration.GetValue<int>("debugport", 4712);
|
||||
Console.WriteLine($"Debugger listening on port:{port}");
|
||||
Console.WriteLine(" use --debugport # or use 'debugport' setting to change)");
|
||||
debugAdapter = new DebugAdapter(port, model, sourceMap, sourceMap, new DebugLogger(nameof(DebugAdapter)));
|
||||
}
|
||||
|
||||
services.AddSingleton<IConfiguration>(this.Configuration);
|
||||
|
|
|
@ -2,15 +2,20 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Rules;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Steps;
|
||||
using Microsoft.Bot.Builder.Dialogs.Debugging;
|
||||
using Microsoft.Bot.Builder.Dialogs.Declarative;
|
||||
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
|
||||
using Microsoft.Bot.Builder.Expressions.Parser;
|
||||
using Microsoft.Bot.Schema;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Recognizers.Text;
|
||||
|
@ -71,13 +76,85 @@ namespace Microsoft.Bot.Builder.TestBot.Json
|
|||
//var rootFile = resourceExplorer.GetResource("ExternalLanguage.main.dialog");
|
||||
//var rootFile = resourceExplorer.GetResource("CustomStep.dialog");
|
||||
|
||||
rootDialog = DeclarativeTypeLoader.Load<IDialog>(rootFile.FullName, resourceExplorer, registry);
|
||||
// rootDialog = DeclarativeTypeLoader.Load<IDialog>(rootFile.FullName, resourceExplorer, registry);
|
||||
rootDialog = LoadCodeDialog();
|
||||
|
||||
_dialogs = new DialogSet(this.dialogState);
|
||||
_dialogs.Add(rootDialog);
|
||||
|
||||
System.Diagnostics.Trace.TraceInformation("Done loading resources.");
|
||||
}
|
||||
|
||||
private AdaptiveDialog LoadCodeDialog()
|
||||
{
|
||||
var expressionParser = new ExpressionEngine();
|
||||
var dialog = new AdaptiveDialog()
|
||||
{
|
||||
AutoEndDialog = false,
|
||||
Recognizer = new RegexRecognizer()
|
||||
{
|
||||
Intents = new Dictionary<string, string>()
|
||||
{
|
||||
{ "Intent1", "intent1" },
|
||||
{ "Intent2", "intent2" },
|
||||
{ "Intent3", "intent3" },
|
||||
{ "Intent4", "intent4" },
|
||||
}
|
||||
},
|
||||
Steps = new List<IDialog>()
|
||||
{
|
||||
new SendActivity("hello1"),
|
||||
new SendActivity("hello2"),
|
||||
new IfCondition()
|
||||
{
|
||||
Condition = expressionParser.Parse("user.name == null"),
|
||||
Steps = new List<IDialog>()
|
||||
{
|
||||
new SendActivity("name is null"),
|
||||
},
|
||||
ElseSteps = new List<IDialog>()
|
||||
{
|
||||
new SendActivity("name is not null"),
|
||||
}
|
||||
},
|
||||
new SendActivity("hello4")
|
||||
},
|
||||
Rules = new List<IRule>()
|
||||
{
|
||||
new IntentRule("Intent1")
|
||||
{
|
||||
Steps = new List<IDialog>()
|
||||
{
|
||||
new SendActivity("Intent 1 triggered")
|
||||
}
|
||||
},
|
||||
new IntentRule("Intent2")
|
||||
{
|
||||
Steps = new List<IDialog>()
|
||||
{
|
||||
new SendActivity("Intent 2 triggered")
|
||||
}
|
||||
},
|
||||
new IntentRule("Intent3")
|
||||
{
|
||||
Steps = new List<IDialog>()
|
||||
{
|
||||
new SendActivity("Intent 3 triggered")
|
||||
}
|
||||
},
|
||||
new UnknownIntentRule()
|
||||
{
|
||||
Steps = new List<IDialog>()
|
||||
{
|
||||
new SendActivity("Wha?")
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (rootDialog is AdaptiveDialog planningDialog)
|
||||
|
|
Загрузка…
Ссылка в новой задаче