-
Notifications
You must be signed in to change notification settings - Fork 15
Deprecate Teams Controllers #281
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
base: main
Are you sure you want to change the base?
Conversation
Added [Obsolete] attribute to main Controller and all test classes in Microsoft.Teams.Apps.Tests.Activities. Suppressed CS0612 warnings for obsolete Controller registration in Program.cs. No functional changes; these updates clarify deprecation status. Add Deprecated.Controllers project and mark old controllers obsolete Created Deprecated.Controllers project targeting .NET 10.0 with Teams and DevTools integration, including a sample MainController. Updated solution file to include the new project. Added configuration and launch settings for local development. Marked existing Controller and Teams activity test classes as [Obsolete] in the main sample app, and suppressed obsolete warnings where necessary.
| WebApplication? webApp = builder as WebApplication; | ||
| ArgumentNullException.ThrowIfNull(webApp, nameof(builder)); | ||
|
|
||
| webApp.MapPost("/api/messages", async (HttpContext httpContext, AspNetCorePlugin plugin, CancellationToken cancellationToken) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure we review this.
It was not strictly required this change to deprecate the TeamsController, but with the goal of removing the MVC/Controllers I decided to listen to /api/messages from a minimal API as well.
| _lifetime = lifetime; | ||
| } | ||
|
|
||
| [HttpPost("/api/messages")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note /api/messages was also hardcoded here
| WebApplication? webApp = builder as WebApplication; | ||
| ArgumentNullException.ThrowIfNull(webApp, nameof(builder)); | ||
|
|
||
| webApp.MapPost("/api/messages", async (HttpContext httpContext, AspNetCorePlugin plugin, CancellationToken cancellationToken) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should expose a variable to configure api/messages
This pull request deprecates the legacy controller-based APIs in favor of Minimal APIs, removes related obsolete infrastructure, and introduces a new sample project to demonstrate the deprecated controller pattern. The main focus is to guide developers toward using Minimal APIs for Teams app development, while still providing backward compatibility and clear migration paths.
Key changes include:
Deprecation of Controller-based APIs:
TeamsControllerAttribute,App.AddController<T>, and relevant controller classes (such asMessageControllerandActivityController) with[Obsolete("Use Minimal APIs instead.")]to indicate deprecation and guide users to Minimal APIs. [1] [2] [3] [4] [5]Removal of Legacy Controller Infrastructure:
RemoveDefaultMessageControllerclass and all code that dynamically registers or manages legacy controllers inHostApplicationBuilderExtensions. This simplifies the registration pipeline and prepares the codebase for exclusive Minimal API usage. [1] [2] [3] [4] [5]Migration to Minimal APIs:
AspNetCorePlugin.Configureto map the/api/messagesendpoint directly using Minimal API routing, replacing the previous controller-based route.New Sample for Deprecated Controllers:
Deprecated.Controllersto demonstrate the legacy controller pattern, including a simpleMainController, configuration files, and launch settings. This serves as a reference for teams transitioning away from controllers. [1] [2] [3] [4] [5] [6] [7]Miscellaneous and Backward Compatibility: