Skip to content

Core/activity extensions#515

Open
MehakBindra wants to merge 8 commits into
mainfrom
core/activity-extensions
Open

Core/activity extensions#515
MehakBindra wants to merge 8 commits into
mainfrom
core/activity-extensions

Conversation

@MehakBindra
Copy link
Copy Markdown
Collaborator

No description provided.

@MehakBindra MehakBindra marked this pull request as ready for review May 16, 2026 00:58
Copilot AI review requested due to automatic review settings May 16, 2026 00:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors “activity extensions” in Microsoft.Teams.Apps by moving entity-manipulation helpers into entity-scoped extension types, expanding fluent APIs for MessageActivity/TeamsActivityBuilder, and updating tests/docs/samples to the new APIs.

Changes:

  • Introduces entity-scoped extension helpers (e.g., quoted replies, targeted message info, stream info, citations, mentions) and routes builder methods through them.
  • Expands MessageActivityExtensions with many fluent With*/Add* helpers and adjusts builder behavior around typed MessageActivity fields.
  • Updates unit tests, migration docs, and samples to reflect renamed/relocated APIs (e.g., WithQuoteAddQuote, targeted message info changes).

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
core/test/Microsoft.Teams.Apps.UnitTests/TeamsActivityTests.cs Updates/reshapes activity conversion/serialization tests; adds coverage for derived/base conversion behavior.
core/test/Microsoft.Teams.Apps.UnitTests/TeamsActivityBuilderTests.cs Adds builder tests for WithFrom syncing, duplicate JSON keys, and new builder entity helpers.
core/test/Microsoft.Teams.Apps.UnitTests/TargetedMessageInfoEntityTests.cs Updates tests to use MessageActivity and AddQuote naming.
core/test/Microsoft.Teams.Apps.UnitTests/QuotedReplyEntityTests.cs Renames builder API usage to AddQuote.
core/test/Microsoft.Teams.Apps.UnitTests/MessageActivityTests.cs Adjusts message mapping/serialization assertions (adds From/Recipient checks, removes commented assertions).
core/test/Microsoft.Teams.Apps.UnitTests/CitationEntityTests.cs Migrates citation/feedback tests to MessageActivity and adds feedback-mode test.
core/src/Microsoft.Teams.Apps/Schema/TeamsConversationAccount.cs Promotes Teams account fields (AAD/user details) to typed JSON properties and changes conversion logic.
core/src/Microsoft.Teams.Apps/Schema/TeamsConversation.cs Updates conversation conversion to use Extract<T> for known Teams fields.
core/src/Microsoft.Teams.Apps/Schema/TeamsChannelData.cs Removes the TeamsChannelData(ChannelData?) conversion constructor.
core/src/Microsoft.Teams.Apps/Schema/TeamsActivityBuilder.cs Routes quoting/targeted-message/mention logic through new entity extension helpers; adds new builder “Add*” helpers.
core/src/Microsoft.Teams.Apps/Schema/TeamsActivity.cs Removes TeamsActivity.AddEntity and keeps builder-based creation as the primary path.
core/src/Microsoft.Teams.Apps/Schema/StreamingActivity.cs Switches stream entity creation to StreamInfoEntityExtensions.
core/src/Microsoft.Teams.Apps/Schema/MessageActivityExtensions.cs Adds extensive fluent APIs for MessageActivity and routes entity operations through new helpers.
core/src/Microsoft.Teams.Apps/Schema/MessageActivity.cs Removes commented legacy property extraction and commented-out properties.
core/src/Microsoft.Teams.Apps/Schema/Entities/TargetedMessageInfoEntity.Extensions.cs New helper for targeted message info (add/get + quote placeholder stripping).
core/src/Microsoft.Teams.Apps/Schema/Entities/StreamInfoEntity.Extensions.cs New helper for stream info entity/channelData wiring.
core/src/Microsoft.Teams.Apps/Schema/Entities/StreamInfoEntity.cs Minor formatting change.
core/src/Microsoft.Teams.Apps/Schema/Entities/SensitiveUsageEntity.Extensions.cs New helper to add/get sensitivity label entities.
core/src/Microsoft.Teams.Apps/Schema/Entities/QuotedReplyEntity.Extensions.cs New helper to add/get quoted reply entities + placeholder handling.
core/src/Microsoft.Teams.Apps/Schema/Entities/ProductInfoEntity.Extensions.cs New helper to add/get product info entity.
core/src/Microsoft.Teams.Apps/Schema/Entities/OMessageEntity.Extensions.cs New helper to get/create root schema.org message entity and apply AI-generated labels.
core/src/Microsoft.Teams.Apps/Schema/Entities/MentionEntity.Extensions.cs New helper to add/get mention entities and optionally prepend mention text.
core/src/Microsoft.Teams.Apps/Schema/Entities/MentionEntity.cs Removes the old ActivityMentionExtensions block (moved to new extensions file).
core/src/Microsoft.Teams.Apps/Schema/Entities/ClientInfoEntity.Extensions.cs New helper to add/get client info entity.
core/src/Microsoft.Teams.Apps/Schema/Entities/ClientInfoEntity.cs Removes the old ActivityClientInfoExtensions block (moved to new extensions file).
core/src/Microsoft.Teams.Apps/Schema/Entities/CitationEntity.Extensions.cs New helper to add/get citation entity built from the root message entity.
core/src/Microsoft.Teams.Apps/Schema/Entities/CitationEntity.cs Removes the old ActivityCitationExtensions block (moved to new extensions files).
core/src/Microsoft.Teams.Apps/Schema/Entities/ActivityTargetedMessageInfoExtensions.cs Deletes prior targeted-message-info implementation (replaced by new entity extensions).
core/src/Microsoft.Teams.Apps/Schema/Entities/ActivityQuotedReplyExtensions.cs Deletes prior quoted-reply implementation (replaced by new entity extensions).
core/src/Microsoft.Teams.Apps/Context.cs Updates targeted-message-info injection to use the new helper.
core/samples/TeamsBot/Program.cs Updates citation sample to use builder-based fluent APIs.
core/samples/Quoting/Program.cs Updates quoting sample to use AddQuote via builder and removes the old WithQuote builder demo.
core/samples/AllFeatures/Program.cs Removes the AllFeatures sample.
core/samples/AllFeatures/appsettings.json Removes AllFeatures sample config.
core/samples/AllFeatures/AllFeatures.http Removes AllFeatures sample HTTP file.
core/samples/AllFeatures/AllFeatures.csproj Removes AllFeatures sample project file.
core/docs/ReduceBreakingChangesPlan.md Updates plan narrative to reflect new extension APIs.
core/docs/MigrationGuide.md Updates migration guidance around entity getters and fluent APIs.
core/core.slnx Removes a docs file reference from the solution items.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 44 to +48
result.AgenticAppBlueprintId = conversationAccount.AgenticAppBlueprintId;
result.Properties = conversationAccount.Properties;
result.AadObjectId = conversationAccount.Properties.Extract<string>("aadObjectId");
result.GivenName = conversationAccount.Properties.Extract<string>("givenName");
result.Surname = conversationAccount.Properties.Extract<string>("surname");
result.Email = conversationAccount.Properties.Extract<string>("email");
Comment on lines +61 to +63
result.TenantId = conversation.Properties.Extract<string>("tenantId");
result.ConversationType = conversation.Properties.Extract<string>("conversationType");
result.IsGroup = conversation.Properties.Extract<bool?>("isGroup");
Comment on lines +94 to +98
ArgumentNullException.ThrowIfNull(value);

message.Conversation = value is TeamsConversation teamsConversation
? teamsConversation
: TeamsConversation.FromConversation(value);
Comment on lines +290 to +298
**New (extension methods on `TeamsActivity`):**
```csharp
var activity = new TeamsActivity()
.WithFrom(account)
.WithConversation(conv)
.WithChannelId("msteams");
```

Most base `With*()` methods are now available as extension methods in `TeamsActivityExtensions` (for example `WithId`, `WithChannelId`, `WithFrom`, `WithRecipient`, `WithConversation`, `WithServiceUrl`, `WithLocale`, `WithTimestamp`, `WithLocalTimestamp`, `WithData`, and `WithAppId`).
### BC-16: `AddSensitivityLabel()` missing on TeamsActivity

**Decision: IMPLEMENTED** — Extension method added in `ActivityCitationExtensions`.
**Decision: IMPLEMENTED** — Extension method added in `TeamsActivityExtensions`.
Comment on lines 58 to 62
/// Creates a new instance of the <see cref="TeamsChannelData"/> class.
/// </summary>
public TeamsChannelData()
{
}
Comment on lines +16 to +20
/// <summary>
/// Builds the inline placeholder element that pairs with a <see cref="QuotedReplyEntity"/>.
/// </summary>
private static readonly Regex QuotedPlaceholderRegex = new("<quoted messageId=\"[^\"]*\"/>");

Comment on lines +86 to 90
.AddClientInfo("Web", "US", "America/Los_Angeles", "en-US")
.Build();

activity.AddClientInfo("Web", "US", "America/Los_Angeles", "en-US");
ClientInfoEntityExtensions.AddToActivity(activity, "Web", "US", "America/Los_Angeles", "en-US");

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