- Notifications
You must be signed in to change notification settings - Fork 492
Add Runtime project and tests #4968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits Select commit Hold shift + click to select a range
739bdf2 Runtime integration with SDK
tracyboehrer c17c609 Fixing tests to handle targeting multiple frameworks based on underly…
peterinnesmsft 56701b3 Renamed Runtime to Microsoft.Bot.Builder.Runtime
tracyboehrer 2829b42 Add remove recipient mention middleware builder to core bot component…
tracyboehrer 776a16b Setup bf-runtime team in CODEOWNERS
tracyboehrer f7d7790 Merge branch 'main' into trboehre/runtime
tracyboehrer 1ecd9b8 Removed Runtime.WebHost
tracyboehrer 75db64d Added Runtime package description and summary
tracyboehrer 5fc42b1 Removed duplicate Runtime project dependency
tracyboehrer 1f02057 Runtime IBuilder TItem -> T
tracyboehrer c242cf3 Switched Runtime to preview package version
tracyboehrer fccee5a Runtime: Removed "I" from non-interface classes. Provided public key…
tracyboehrer 328966d Runtime: Removed Dialog.Debugging dependency
tracyboehrer 7747555 Merge branch 'main' into trboehre/runtime
tracyboehrer f202e2f Merge branch 'main' into trboehre/runtime
tracyboehrer 895bc5c Adding documentation headers to Microsoft.Bot.Builder.Runtime classes.
peterinnesmsft 14861e0 CoreBot now implements IBot instead of extending ActivityHandler
tracyboehrer 31f2fb9 Runtime: Removed TODO's
tracyboehrer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions 26 libraries/Microsoft.Bot.Builder.Runtime/Builders/IBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| | ||
| using System; | ||
| using Microsoft.Extensions.Configuration; | ||
| | ||
| namespace Microsoft.Bot.Builder.Runtime.Builders | ||
| { | ||
| /// <summary> | ||
| /// Defines an interface used to build an instance of the specified type using supplied application | ||
| /// configuration and registered services. | ||
| /// </summary> | ||
| /// <typeparam name="T">The type of the object to be returned by the builder.</typeparam> | ||
| public interface IBuilder<out T> | ||
| { | ||
| /// <summary> | ||
| /// Builds an instance of type <typeparamref name="T"/>. | ||
| /// </summary> | ||
| /// <param name="services"> | ||
| /// Provider containing all services registered with the application's service collection. | ||
| /// </param> | ||
| /// <param name="configuration">Application configuration.</param> | ||
| /// <returns>An instance of type <typeparamref name="T"/>.</returns> | ||
| T Build(IServiceProvider services, IConfiguration configuration); | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions 13 libraries/Microsoft.Bot.Builder.Runtime/Builders/Middleware/IMiddlewareBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| | ||
| namespace Microsoft.Bot.Builder.Runtime.Builders.Middleware | ||
| { | ||
| /// <summary> | ||
| /// Defines an interface for an implementation of <see cref="IBuilder{T}"/> that returns an | ||
| /// instance whose type implements <see cref="IMiddleware" />. | ||
| /// </summary> | ||
| public interface IMiddlewareBuilder : IBuilder<IMiddleware> | ||
| { | ||
| } | ||
| } | ||
49 changes: 49 additions & 0 deletions 49 libraries/Microsoft.Bot.Builder.Runtime/Builders/Middleware/InspectionMiddlewareBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| | ||
| using System; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Newtonsoft.Json; | ||
| | ||
| namespace Microsoft.Bot.Builder.Runtime.Builders.Middleware | ||
| { | ||
| /// <summary> | ||
| /// Defines an implementation of <see cref="IMiddlewareBuilder"/> that returns an instance | ||
| /// of <see cref="InspectionMiddleware"/>. | ||
| /// </summary> | ||
| [JsonObject] | ||
| public class InspectionMiddlewareBuilder : IMiddlewareBuilder | ||
peterinnesmsft marked this conversation as resolved. Show resolved Hide resolved | ||
| { | ||
| /// <summary> | ||
| /// Class identifier. | ||
| /// </summary> | ||
| [JsonProperty("$kind")] | ||
| public const string Kind = "Microsoft.InspectionMiddleware"; | ||
| | ||
| /// <summary> | ||
| /// Builds an instance of type <see cref="InspectionMiddleware"/>. | ||
| /// </summary> | ||
| /// <param name="services"> | ||
| /// Provider containing all services registered with the application's service collection. | ||
| /// </param> | ||
| /// <param name="configuration">Application configuration.</param> | ||
| /// <returns>An instance of type <see cref="InspectionMiddleware"/>.</returns> | ||
| public IMiddleware Build(IServiceProvider services, IConfiguration configuration) | ||
| { | ||
| if (services == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(services)); | ||
| } | ||
| | ||
| if (configuration == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(configuration)); | ||
| } | ||
| | ||
| var storage = services.GetService<IStorage>(); | ||
| | ||
| return new InspectionMiddleware(new InspectionState(storage)); | ||
| } | ||
| } | ||
| } | ||
71 changes: 71 additions & 0 deletions 71 ...rosoft.Bot.Builder.Runtime/Builders/Middleware/RemoveRecipientMentionMiddlewareBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| | ||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Bot.Schema; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Newtonsoft.Json; | ||
| | ||
| namespace Microsoft.Bot.Builder.Runtime.Builders.Middleware | ||
| { | ||
| /// <summary> | ||
| /// Defines an implementation of <see cref="IMiddlewareBuilder"/> that returns an instance | ||
| /// of <see cref="RemoveRecipientMentionMiddlewareBuilder"/>. | ||
| /// </summary> | ||
| [JsonObject] | ||
| public class RemoveRecipientMentionMiddlewareBuilder : IMiddleware, IMiddlewareBuilder | ||
| { | ||
| /// <summary> | ||
| /// Class identifier. | ||
| /// </summary> | ||
| [JsonProperty("$kind")] | ||
| public const string Kind = "Microsoft.RemoveRecipientMentionMiddleware"; | ||
| | ||
| /// <summary> | ||
| /// Builds an instance of type <see cref="RemoveRecipientMentionMiddlewareBuilder"/>. | ||
| /// </summary> | ||
| /// <param name="services"> | ||
| /// Provider containing all services registered with the application's service collection. | ||
| /// </param> | ||
| /// <param name="configuration">Application configuration.</param> | ||
| /// <returns>An instance of type <see cref="RemoveRecipientMentionMiddlewareBuilder"/>.</returns> | ||
| public IMiddleware Build(IServiceProvider services, IConfiguration configuration) | ||
| { | ||
| if (services == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(services)); | ||
| } | ||
| | ||
| if (configuration == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(configuration)); | ||
| } | ||
| | ||
| return this; | ||
| } | ||
| | ||
| /// <summary> | ||
| /// Processes an incoming activity. | ||
| /// </summary> | ||
| /// <param name="turnContext">The context object for this turn.</param> | ||
| /// <param name="next">The delegate to call to continue the bot middleware pipeline.</param> | ||
| /// <param name="cancellationToken">A cancellation token that can be used by other objects | ||
| /// or threads to receive notice of cancellation.</param> | ||
| /// <returns>A task that represents the work queued to execute.</returns> | ||
| /// <remarks>Spawns a thread that sends the periodic typing activities until the turn ends. | ||
| /// </remarks> | ||
| /// <seealso cref="ITurnContext"/> | ||
| /// <seealso cref="Bot.Schema.IActivity"/> | ||
| public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) | ||
| { | ||
| if (turnContext?.Activity?.Type == ActivityTypes.Message) | ||
| { | ||
| turnContext.Activity.RemoveRecipientMention(); | ||
| } | ||
| | ||
| await next(cancellationToken).ConfigureAwait(false); | ||
| } | ||
| } | ||
| } |
75 changes: 75 additions & 0 deletions 75 libraries/Microsoft.Bot.Builder.Runtime/Builders/Middleware/ShowTypingMiddlewareBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| | ||
| using System; | ||
| using AdaptiveExpressions.Properties; | ||
| using Microsoft.Bot.Builder.Runtime.Extensions; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Newtonsoft.Json; | ||
| | ||
| namespace Microsoft.Bot.Builder.Runtime.Builders.Middleware | ||
| { | ||
| /// <summary> | ||
| /// Defines an implementation of <see cref="IMiddlewareBuilder"/> that returns an instance | ||
| /// of <see cref="ShowTypingMiddleware"/>. | ||
| /// </summary> | ||
| [JsonObject] | ||
| public class ShowTypingMiddlewareBuilder : IMiddlewareBuilder | ||
| { | ||
| /// <summary> | ||
| /// Class identifier. | ||
| /// </summary> | ||
| [JsonProperty("$kind")] | ||
| public const string Kind = "Microsoft.ShowTypingMiddleware"; | ||
| | ||
| private const int DefaultDelay = 500; | ||
| private const int DefaultPeriod = 2000; | ||
| | ||
| /// <summary> | ||
| /// Gets or sets the duration in milliseconds to delay before sending the first typing indicator. | ||
| /// Defaults to 500. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The duration in milliseconds to delay before sending the first typing indicator. | ||
| /// Defaults to 500. | ||
| /// </value> | ||
| [JsonProperty("delay")] | ||
| public IntExpression Delay { get; set; } | ||
| | ||
| /// <summary> | ||
| /// Gets or sets the interval in milliseconds at which additional typing indicators will be sent. | ||
| /// Defaults to 2000. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The interval in milliseconds at which additional typing indicators will be sent. | ||
| /// Defaults to 2000. | ||
| /// </value> | ||
| [JsonProperty("period")] | ||
| public IntExpression Period { get; set; } | ||
| | ||
| /// <summary> | ||
| /// Builds an instance of type <see cref="ShowTypingMiddleware"/>. | ||
| /// </summary> | ||
| /// <param name="services"> | ||
| /// Provider containing all services registered with the application's service collection. | ||
| /// </param> | ||
| /// <param name="configuration">Application configuration.</param> | ||
| /// <returns>An instance of type <see cref="ShowTypingMiddleware"/>.</returns> | ||
| public IMiddleware Build(IServiceProvider services, IConfiguration configuration) | ||
| { | ||
| if (services == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(services)); | ||
| } | ||
| | ||
| if (configuration == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(configuration)); | ||
| } | ||
| | ||
| return new ShowTypingMiddleware( | ||
| delay: this.Delay?.GetConfigurationValue(configuration) ?? DefaultDelay, | ||
| period: this.Period?.GetConfigurationValue(configuration) ?? DefaultPeriod); | ||
| } | ||
| } | ||
| } |
77 changes: 77 additions & 0 deletions 77 libraries/Microsoft.Bot.Builder.Runtime/Builders/Middleware/TelemetryMiddlewareBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| | ||
| using System; | ||
| using AdaptiveExpressions.Properties; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.Bot.Builder.Integration.ApplicationInsights.Core; | ||
| using Microsoft.Bot.Builder.Runtime.Extensions; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Newtonsoft.Json; | ||
| | ||
| namespace Microsoft.Bot.Builder.Runtime.Builders.Middleware | ||
| { | ||
| /// <summary> | ||
| /// Defines an implementation of <see cref="IMiddlewareBuilder"/> that returns an instance | ||
| /// of <see cref="TelemetryInitializerMiddleware"/>. | ||
| /// </summary> | ||
| [JsonObject] | ||
| public class TelemetryMiddlewareBuilder : IMiddlewareBuilder | ||
| { | ||
| /// <summary> | ||
| /// Class identifier. | ||
| /// </summary> | ||
| [JsonProperty("$kind")] | ||
| public const string Kind = "Microsoft.TelemetryMiddleware"; | ||
| | ||
| /// <summary> | ||
| /// Gets or sets whether to enable logging of activity events. Defaults to true. | ||
| /// </summary> | ||
| /// <value> | ||
| /// Indicates whether to enable logging of activity events. Defaults to true. | ||
| /// </value> | ||
| [JsonProperty("logActivities")] | ||
| public BoolExpression LogActivities { get; set; } | ||
| | ||
| /// <summary> | ||
| /// Gets or sets whether include personally identifiable information (PII) in log events. Defaults to false. | ||
| /// </summary> | ||
| /// <value> | ||
| /// Indicates whether include personally identifiable information (PII) in log events. Defaults to false. | ||
| /// </value> | ||
| [JsonProperty("logPersonalInformation")] | ||
| public BoolExpression LogPersonalInformation { get; set; } | ||
| | ||
| /// <summary> | ||
| /// Builds an instance of type <see cref="TelemetryInitializerMiddleware"/>. | ||
| /// </summary> | ||
| /// <param name="services"> | ||
| /// Provider containing all services registered with the application's service collection. | ||
| /// </param> | ||
| /// <param name="configuration">Application configuration.</param> | ||
| /// <returns>An instance of type <see cref="TelemetryInitializerMiddleware"/>.</returns> | ||
| public IMiddleware Build(IServiceProvider services, IConfiguration configuration) | ||
| { | ||
| if (services == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(services)); | ||
| } | ||
| | ||
| if (configuration == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(configuration)); | ||
| } | ||
| | ||
| var botTelemetryClient = services.GetService<IBotTelemetryClient>(); | ||
| var httpContextAccessor = services.GetService<IHttpContextAccessor>(); | ||
| | ||
| return new TelemetryInitializerMiddleware( | ||
| httpContextAccessor: httpContextAccessor, | ||
| telemetryLoggerMiddleware: new TelemetryLoggerMiddleware( | ||
| telemetryClient: botTelemetryClient, | ||
| logPersonalInformation: this.LogPersonalInformation?.GetConfigurationValue(configuration) ?? false), | ||
| logActivityTelemetry: this.LogActivities?.GetConfigurationValue(configuration) ?? true); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.