microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
main

Branches

Tags

  • No tags available.
71Branches16Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Commit

Simplify dependency management for TeamsBotApplication (#521)

This pull request refactors the Teams bot application hosting model to
simplify bot setup and handler registration, unify options management,
and streamline dependency injection. Key changes include updating the
`TeamsBotApplication` constructor and options pattern, consolidating
handler registration into bot subclasses, and improving the `ApiClient`
interface. The sample bots and tests are updated to reflect these
changes.

**TeamsBotApplication and Options Refactoring:**

* The `TeamsBotApplication` constructor now takes an `ApiClient`,
`IHttpContextAccessor`, a logger, and an optional
`TeamsBotApplicationOptions`, consolidating the previously separate
conversation and user token clients into the `ApiClient`. The options
class now inherits from `BotApplicationOptions` for unified
configuration.

**Sample Bot Simplification:**

* The ExtAIBot sample is refactored: handler registration is moved from
a static extension method into the `ExtAIBotApp` class constructor, and
the DI registration is updated to use the new hosting model.

**ApiClient Interface Improvements:**

* `ApiClient` now exposes `ConversationClient` and `UserTokenClient` as
internal properties instead of private fields, improving testability and
consistency. All constructors and copy methods are updated accordingly.

**Configuration and Dependency Injection Updates:**

* The Teams bot options now automatically set the `AppId` from the
resolved bot configuration. The ExtAIBot sample's `appsettings.json` and
DI registrations are updated to match the new options and Azure OpenAI
configuration pattern.

**Test and Code Cleanup:**

* Unit tests are updated to use the new constructor patterns, and
unnecessary project references are removed.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Rido <rido-min@users.noreply.github.com>
Changed files1010 shown on this page
Branches0Containing branches
Tags0Containing tags