/// <summary> /// Enable Debug Adapter Protocol for the running adapter. /// </summary> /// <param name="botAdapter">The <see cref="BotAdapter"/> to enable.</param> /// <param name="port">port to listen on.</param> /// <param name="sourceMap">ISourceMap to use (default will be SourceMap()).</param> /// <param name="breakpoints">IBreakpoints to use (default will be SourceMap()).</param> /// <param name="terminate">Termination function (Default is Environment.Exit().</param> /// <param name="events">IEvents to use (Default is Events).</param> /// <param name="codeModel">ICodeModel to use (default is internal implementation).</param> /// <param name="dataModel">IDataModel to use (default is internal implementation).</param> /// <param name="logger">ILogger to use (Default is NullLogger).</param> /// <returns>The <see cref="BotAdapter"/>.</returns> public static BotAdapter UseDebugger( this BotAdapter botAdapter, int port, ISourceMap sourceMap = null, IBreakpoints breakpoints = null, Action terminate = null, IEvents events = null, ICodeModel codeModel = null, IDataModel dataModel = null, ILogger logger = null) { codeModel = codeModel ?? new CodeModel(); DebugSupport.SourceMap = sourceMap ?? new DebuggerSourceMap(codeModel); return(botAdapter.Use( #pragma warning disable CA2000 // Dispose objects before losing scope (excluding, the object ownership is transferred to the adapter and the adapter should dispose it) new DialogDebugAdapter( port: port, sourceMap: DebugSupport.SourceMap, breakpoints: breakpoints ?? DebugSupport.SourceMap as IBreakpoints, terminate: terminate, events: events, codeModel: codeModel, dataModel: dataModel, logger: logger))); #pragma warning restore CA2000 // Dispose objects before losing scope }
/// <summary> /// Enable Debug Adapter Protocol for the running adapter. /// </summary> /// <param name="botAdapter">The <see cref="BotAdapter"/> to enable.</param> /// <param name="port">port to listen on.</param> /// <param name="sourceMap">ISourceMap to use (default will be SourceMap()).</param> /// <param name="breakpoints">IBreakpoints to use (default will be SourceMap()).</param> /// <param name="terminate">Termination function (Default is Environment.Exit().</param> /// <param name="events">IEvents to use (Default is Events).</param> /// <param name="codeModel">ICodeModel to use (default is internal implementation).</param> /// <param name="dataModel">IDataModel to use (default is internal implementation).</param> /// <param name="logger">ILogger to use (Default is NullLogger).</param> /// <param name="coercion">ICoercion to use (default is internal implementation).</param> /// <returns>The <see cref="BotAdapter"/>.</returns> public static BotAdapter UseDebugger( this BotAdapter botAdapter, int port, ISourceMap sourceMap = null, IBreakpoints breakpoints = null, Action terminate = null, IEvents events = null, ICodeModel codeModel = null, IDataModel dataModel = null, ILogger logger = null, ICoercion coercion = null) { codeModel = codeModel ?? new CodeModel(); DebugSupport.SourceMap = sourceMap ?? new DebuggerSourceMap(codeModel); return(botAdapter.Use( new DialogDebugAdapter( port: port, sourceMap: DebugSupport.SourceMap, breakpoints: breakpoints ?? DebugSupport.SourceMap as IBreakpoints, terminate: terminate, events: events, codeModel: codeModel, dataModel: dataModel, logger: logger))); }
public DialogDebugAdapter(int port, ISourceMap sourceMap, IBreakpoints breakpoints, Action terminate, IEvents events = null, ICodeModel codeModel = null, IDataModel dataModel = null, ILogger logger = null, ICoercion coercion = null) : base(logger) { this.events = events ?? new Events<DialogEvents>(); this.codeModel = codeModel ?? new CodeModel(); this.dataModel = dataModel ?? new DataModel(coercion ?? new Coercion()); this.sourceMap = sourceMap ?? throw new ArgumentNullException(nameof(sourceMap)); this.breakpoints = breakpoints ?? throw new ArgumentNullException(nameof(breakpoints)); this.terminate = terminate ?? new Action(() => Environment.Exit(0)); this.task = ListenAsync(new IPEndPoint(IPAddress.Any, port), cancellationToken.Token); }
public DialogDebugAdapter(IDebugTransport transport, ISourceMap sourceMap, IBreakpoints breakpoints, Action terminate, IEvents events = null, ICodeModel codeModel = null, IDataModel dataModel = null, ILogger logger = null, ICoercion coercion = null) { _transport = transport ?? throw new ArgumentNullException(nameof(transport)); _events = events ?? new Events <DialogEvents>(); _codeModel = codeModel ?? new CodeModel(); _dataModel = dataModel ?? new DataModel(coercion ?? new Coercion()); _sourceMap = sourceMap ?? throw new ArgumentNullException(nameof(sourceMap)); _breakpoints = breakpoints ?? throw new ArgumentNullException(nameof(breakpoints)); _terminate = terminate ?? (() => Environment.Exit(0)); _logger = logger ?? NullLogger.Instance; _arenas.Add(_output); // lazily complete circular dependency _transport.Accept = AcceptAsync; }