Skip to content
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

Add missing code docs to integration libraries #4137

Merged
merged 4 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@

namespace Microsoft.Bot.Builder.Integration.ApplicationInsights.Core
{
/// <summary>
/// ApplicationBuilder extension methods for use when registering Application Insights services at startup.
/// </summary>
public static class ApplicationBuilderExtensions
{
/// <summary>
/// Constant key used for Application Insights Instrumentation Key.
/// </summary>
public const string AppInsightsInstrumentationKey = "ApplicationInsights:InstrumentationKey";

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<!-- These documentation warnings excludes should be removed as part of https://github.com/microsoft/botbuilder-dotnet/issues/4052 -->
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Microsoft.Bot.Builder.Integration.ApplicationInsights.Core
{
/// <summary>
/// Services collection extension methods for use when configuring Application Insights at startup.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ namespace Microsoft.Bot.Builder.Integration.ApplicationInsights.Core
/// </summary>
public class TelemetryBotIdInitializer : ITelemetryInitializer
{
/// <summary>
/// Constant key used for storing activity information in turn state.
/// </summary>
public static readonly string BotActivityKey = "BotBuilderActivity";

private readonly IHttpContextAccessor _httpContextAccessor;

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryBotIdInitializer"/> class.
/// </summary>
/// <param name="httpContextAccessor">The HttpContextAccessor used to access the current HttpContext.</param>
public TelemetryBotIdInitializer(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
}

/// <inheritdoc/>
public void Initialize(ITelemetry telemetry)
{
if (telemetry == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@

namespace Microsoft.Bot.Builder.Integration.ApplicationInsights.Core
{
// This class has been deprecated in favor of using TelemetryInitializerMiddleware in
// Microsoft.Bot.Integration.ApplicationInsights.Core and Microsoft.Bot.Integration.ApplicationInsights.WebApi
/// <summary>
/// Middleware to store the incoming activity request body into the HttpContext items collection.
/// This class has been deprecated in favor of using TelemetryInitializerMiddleware in
/// Microsoft.Bot.Integration.ApplicationInsights.Core and Microsoft.Bot.Integration.ApplicationInsights.WebApi.
/// </summary>
[Obsolete("This class is deprecated. Please add TelemetryInitializerMiddleware to your adapter's middleware pipeline instead.")]
public class TelemetrySaveBodyASPMiddleware
{
private readonly RequestDelegate _next;

/// <summary>
/// Initializes a new instance of the <see cref="TelemetrySaveBodyASPMiddleware"/> class.
/// </summary>
/// <param name="next">The delegate to the next piece of middleware in the pipeline.</param>
public TelemetrySaveBodyASPMiddleware(RequestDelegate next)
{
_next = next ?? throw new ArgumentNullException(nameof(next));
}

/// <summary>
/// Invokes the TelemetrySaveBodyASPMiddleware middleware.
/// </summary>
/// <param name="httpContext">The HttpContext.</param>
/// <returns>A task that represents the work queued to execute.</returns>
public async Task Invoke(HttpContext httpContext)
{
var request = httpContext.Request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<!-- These documentation warnings excludes should be removed as part of https://github.com/microsoft/botbuilder-dotnet/issues/4052 -->
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<PropertyGroup>
<AssemblyName>Microsoft.Bot.Builder.Integration.ApplicationInsights.WebApi</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ namespace Microsoft.Bot.Builder.Integration.ApplicationInsights.WebApi
/// </summary>
public class TelemetryBotIdInitializer : ITelemetryInitializer
{
/// <summary>
/// Constant key used for storing activity information in turn state.
/// </summary>
public static readonly string BotActivityKey = "BotBuilderActivity";

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryBotIdInitializer"/> class.
/// </summary>
/// <param name="telemetry">The telemetry item to be logged to Application Insights.</param>
public void Initialize(ITelemetry telemetry)
{
var httpContext = HttpContext.Current;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,42 @@ public BotFrameworkHttpAdapter(
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BotFrameworkHttpAdapter"/> class,
/// using a credential provider.
/// </summary>
/// <param name="credentialProvider">The credential provider.</param>
/// <param name="channelProvider">The channel provider.</param>
/// <param name="logger">The ILogger implementation this adapter should use.</param>
public BotFrameworkHttpAdapter(ICredentialProvider credentialProvider = null, IChannelProvider channelProvider = null, ILogger<BotFrameworkHttpAdapter> logger = null)
: this(credentialProvider ?? new SimpleCredentialProvider(), new AuthenticationConfiguration(), channelProvider, null, null, null, logger)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BotFrameworkHttpAdapter"/> class,
/// using a credential provider.
/// </summary>
/// <param name="credentialProvider">The credential provider.</param>
/// <param name="channelProvider">The channel provider.</param>
/// <param name="httpClient">The <see cref="HttpClient"/> used.</param>
/// <param name="logger">The ILogger implementation this adapter should use.</param>
public BotFrameworkHttpAdapter(ICredentialProvider credentialProvider, IChannelProvider channelProvider, HttpClient httpClient, ILogger<BotFrameworkHttpAdapter> logger)
: this(credentialProvider ?? new SimpleCredentialProvider(), new AuthenticationConfiguration(), channelProvider, null, httpClient, null, logger)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BotFrameworkHttpAdapter"/> class.
/// </summary>
/// <param name="configuration">An <see cref="IConfiguration"/> instance.</param>
/// <param name="credentialProvider">The credential provider.</param>
/// <param name="authConfig">The authentication configuration.</param>
/// <param name="channelProvider">The channel provider.</param>
/// <param name="connectorClientRetryPolicy">Retry policy for retrying HTTP operations.</param>
/// <param name="customHttpClient">The HTTP client.</param>
/// <param name="middleware">The middleware to initially add to the adapter.</param>
/// <param name="logger">The ILogger implementation this adapter should use.</param>
protected BotFrameworkHttpAdapter(
IConfiguration configuration,
ICredentialProvider credentialProvider,
Expand All @@ -87,11 +113,25 @@ protected BotFrameworkHttpAdapter(
}
}

/// <summary>
/// Initializes a new instance of the <see cref="BotFrameworkHttpAdapter"/> class.
/// </summary>
/// <param name="configuration">An <see cref="IConfiguration"/> instance.</param>
/// <param name="logger">The ILogger implementation this adapter should use.</param>
protected BotFrameworkHttpAdapter(IConfiguration configuration, ILogger<BotFrameworkHttpAdapter> logger = null)
: this(configuration, new ConfigurationCredentialProvider(configuration), new AuthenticationConfiguration(), new ConfigurationChannelProvider(configuration), logger: logger)
{
}

/// <summary>
/// This method can be called from inside a POST method on any Controller implementation.
/// </summary>
/// <param name="httpRequest">The HTTP request object, typically in a POST handler by a Controller.</param>
/// <param name="httpResponse">The HTTP response object.</param>
/// <param name="bot">The bot implementation.</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>
public async Task ProcessAsync(HttpRequest httpRequest, HttpResponse httpResponse, IBot bot, CancellationToken cancellationToken = default)
{
if (httpRequest == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@

namespace Microsoft.Bot.Builder.Integration.AspNet.Core
{
/// <summary>
/// A client for posting Bot Framework activities.
/// </summary>
public class BotFrameworkHttpClient : BotFrameworkClient
{
/// <summary>
/// Initializes a new instance of the <see cref="BotFrameworkHttpClient"/> class.
/// </summary>
/// <param name="httpClient">A <see cref="HttpClient"/>.</param>
/// <param name="credentialProvider">An instance of <see cref="ICredentialProvider"/>.</param>
/// <param name="channelProvider">An instance of <see cref="IChannelProvider"/>.</param>
/// <param name="logger">An instance of <see cref="ILogger"/>.</param>
public BotFrameworkHttpClient(
HttpClient httpClient,
ICredentialProvider credentialProvider,
Expand All @@ -33,18 +43,56 @@ public BotFrameworkHttpClient(
ConnectorClient.AddDefaultRequestHeaders(HttpClient);
}

// Cache for appCredentials to speed up token acquisition (a token is not requested unless is expired)
// AppCredentials are cached using appId + scope (this last parameter is only used if the app credentials are used to call a skill)
/// <summary>
/// Gets the Cache for appCredentials to speed up token acquisition (a token is not requested unless is expired).
/// AppCredentials are cached using appId + scope (this last parameter is only used if the app credentials are used to call a skill).
/// </summary>
/// <value>ConcurrentDictionary of <see cref="AppCredentials"/>.</value>
protected static ConcurrentDictionary<string, AppCredentials> AppCredentialMapCache { get; } = new ConcurrentDictionary<string, AppCredentials>();

/// <summary>
/// Gets the channel provider for this adapter.
/// </summary>
/// <value>
/// The channel provider for this adapter.
/// </value>
protected IChannelProvider ChannelProvider { get; }

/// <summary>
/// Gets the credential provider for this adapter.
/// </summary>
/// <value>
/// The credential provider for this adapter.
/// </value>
protected ICredentialProvider CredentialProvider { get; }

/// <summary>
/// Gets the HttpClient for this adapter.
/// </summary>
/// <value>
/// The HttpClient for this adapter.
/// </value>
protected HttpClient HttpClient { get; }

/// <summary>
/// Gets the logger for this adapter.
/// </summary>
/// <value>
/// The logger for this adapter.
/// </value>
protected ILogger Logger { get; }

/// <summary>
/// Forwards an activity to a skill (bot).
/// </summary>
/// <param name="fromBotId">The MicrosoftAppId of the bot sending the activity.</param>
/// <param name="toBotId">The MicrosoftAppId of the bot receiving the activity.</param>
/// <param name="toUrl">The URL of the bot receiving the activity.</param>
/// <param name="serviceUrl">The callback Url for the skill host.</param>
/// <param name="conversationId">A conversation ID to use for the conversation with the skill.</param>
/// <param name="activity">activity to forward.</param>
/// <param name="cancellationToken">cancellation Token.</param>
/// <returns>Async task with optional invokeResponse.</returns>
public override async Task<InvokeResponse> PostActivityAsync(string fromBotId, string toBotId, Uri toUrl, Uri serviceUrl, string conversationId, Activity activity, CancellationToken cancellationToken = default)
{
return await PostActivityAsync<object>(fromBotId, toBotId, toUrl, serviceUrl, conversationId, activity, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@

namespace Microsoft.Bot.Builder.Integration.AspNet.Core.Handlers
{
/// <summary>
/// A handler to process incoming http requests via using an adapter.
/// </summary>
public class BotMessageHandler : BotMessageHandlerBase
{
/// <summary>
/// Deserializes the incoming request using a BotMessageHandler, processes it with an <see cref="IAdapterIntegration"/>
/// and returns an <see cref="InvokeResponse"/>.
/// </summary>
/// <param name="request">A <see cref="HttpRequest"/>.</param>
/// <param name="adapter">An instance of <see cref="IAdapterIntegration"/>.</param>
/// <param name="botCallbackHandler">An instance of <see cref="BotCallbackHandler"/>.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/>.</param>
/// <returns>An <see cref="InvokeResponse"/> returned from the adapter.</returns>
protected override async Task<InvokeResponse> ProcessMessageRequestAsync(HttpRequest request, IAdapterIntegration adapter, BotCallbackHandler botCallbackHandler, CancellationToken cancellationToken)
{
var activity = default(Activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,29 @@

namespace Microsoft.Bot.Builder.Integration.AspNet.Core.Handlers
{
/// <summary>
/// Abstract base class for a bot message handler.
/// </summary>
public abstract class BotMessageHandlerBase
{
/// <summary>
/// A <see cref="JsonSerializer"/> for use when serializing bot messages.
/// </summary>
public static readonly JsonSerializer BotMessageSerializer = JsonSerializer.Create(MessageSerializerSettings.Create());

/// <summary>
/// Initializes a new instance of the <see cref="BotMessageHandlerBase"/> class.
/// </summary>
public BotMessageHandlerBase()
{
}

/// <summary>
/// Handles common behavior for handling requests, including checking valid request method and content type.
/// Processes the request using the registered adapter and bot and writes the result to the response on the <see cref="HttpContext"/>.
/// </summary>
/// <param name="httpContext">The <see cref="HttpContext"/>.</param>
/// <returns>A Task that represents the work to be executed.</returns>
public async Task HandleAsync(HttpContext httpContext)
{
var request = httpContext.Request;
Expand Down Expand Up @@ -98,6 +113,15 @@ public async Task HandleAsync(HttpContext httpContext)
}
}

/// <summary>
/// Abstract method to process the incoming request using the registered adapter and bot and
/// to return an <see cref="InvokeResponse"/>.
/// </summary>
/// <param name="request">A <see cref="HttpRequest"/>.</param>
/// <param name="adapter">An instance of <see cref="IAdapterIntegration"/>.</param>
/// <param name="botCallbackHandler">An instance of <see cref="BotCallbackHandler"/>.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/>.</param>
/// <returns>An <see cref="InvokeResponse"/> returned from the adapter.</returns>
protected abstract Task<InvokeResponse> ProcessMessageRequestAsync(HttpRequest request, IAdapterIntegration adapter, BotCallbackHandler botCallbackHandler, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public sealed class ConfigurationChannelProvider : SimpleChannelProvider
/// </summary>
public const string ChannelServiceKey = "ChannelService";

/// <summary>
/// Initializes a new instance of the <see cref="ConfigurationChannelProvider"/> class.
/// </summary>
/// <param name="configuration">An instance of <see cref="IConfiguration"/>.</param>
public ConfigurationChannelProvider(IConfiguration configuration)
{
this.ChannelService = configuration.GetSection(ChannelServiceKey)?.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ namespace Microsoft.Bot.Builder.BotFramework
/// </remarks>
public sealed class ConfigurationCredentialProvider : SimpleCredentialProvider
{
/// <summary>
/// Initializes a new instance of the <see cref="ConfigurationCredentialProvider"/> class.
/// </summary>
/// <param name="configuration">An instance of <see cref="IConfiguration"/>.</param>
public ConfigurationCredentialProvider(IConfiguration configuration)
{
this.AppId = configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value;
Expand Down
Loading