Skip to content

Conversation

@rido-min
Copy link
Member

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:

  • Marked TeamsControllerAttribute, App.AddController<T>, and relevant controller classes (such as MessageController and ActivityController) 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:

  • Removed the RemoveDefaultMessageController class and all code that dynamically registers or manages legacy controllers in HostApplicationBuilderExtensions. This simplifies the registration pipeline and prepares the codebase for exclusive Minimal API usage. [1] [2] [3] [4] [5]

Migration to Minimal APIs:

  • Updated AspNetCorePlugin.Configure to map the /api/messages endpoint directly using Minimal API routing, replacing the previous controller-based route.

New Sample for Deprecated Controllers:

  • Added a new sample project Deprecated.Controllers to demonstrate the legacy controller pattern, including a simple MainController, 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:

  • Updated solution files to include the new sample and support Visual Studio 18. [1] [2] [3]
  • Suppressed obsolete warnings in places where legacy APIs are still used in samples for demonstration purposes. [1] [2] [3]
  • Minor updates to sample projects to use the new dev tools and maintain compatibility. [1] [2]

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) =>
Copy link
Member Author

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")]
Copy link
Member Author

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) =>
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants