Add fluent builder helpers to Core.Models (ease-of-use)#932
Draft
tracyboehrer wants to merge 1 commit into
Draft
Add fluent builder helpers to Core.Models (ease-of-use)#932tracyboehrer wants to merge 1 commit into
tracyboehrer wants to merge 1 commit into
Conversation
Adds non-breaking, additive fluent/builder extensions to Microsoft.Agents.Core.Models, inspired by the ergonomic API style of microsoft/teams.net (Microsoft.Teams.Api). - ActivityBuilderExtensions: chainable With*/Add* methods on IActivity, card AddAttachment overloads, AddMention, AddEntity, and Is<Type>() helpers. - IActivityExtensions: GetAccountMention(id) and IsRecipientMentioned(). - SuggestedActions: fluent AddAction/AddActions/AddRecipients. - CardBuilderExtensions: fluent builders for Hero/Thumbnail/Basic/Animation/Audio/ Video/Media/Receipt cards (With*/AddImage/AddMedia/AddButton, etc.). - Tests covering all new helpers (net8.0 + net4.8). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a5b5eb02-9d4a-426c-9c0a-8c5699675860
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds non-breaking, purely additive fluent/builder helpers to
Microsoft.Agents.Core.Models, closing an ergonomics gap identified by comparing the SDK models againstmicrosoft/teams.net(Microsoft.Teams.Api). The Agents SDK models are structurally equivalent, but teams.net offers a fluent, chainable builder style that the Agents SDK lacked. Every addition here is a new method/overload — no signature, type, or serialization changes, so nothing breaks for existing consumers.What's added
ActivityBuilderExtensions.cs(new) — chainable extensions onIActivity(compose nicely with the existingActivity.Create*factories):WithText,WithSpeak,WithInputHint,WithSummary,WithLocale,WithTextFormat,WithAttachmentLayout,WithDeliveryMode,WithName,WithValue,WithSuggestedActionsAddText(append),AddAttachment(params Attachment[]), plus overloads that auto-wrapHeroCard/ThumbnailCard/AnimationCard/AudioCard/VideoCard/ReceiptCard/OAuthCard/SigninCardAddEntity,AddMention(account, text, addText)— injects<at>markup + aMentionentityIsMessage,IsEvent,IsInvoke,IsTyping,IsConversationUpdate,IsEndOfConversation,IsHandoff,IsTrace,IsCommand,IsCommandResultIActivityExtensions.cs—GetAccountMention(id)andIsRecipientMentioned()(parity with teams.net mention query helpers; complements the existingGetMentions()).SuggestedActions.cs— fluentAddAction,AddActions,AddRecipients(returnthis).CardBuilderExtensions.cs(new) — fluent builders acrossHeroCard,ThumbnailCard,BasicCard,AnimationCard,AudioCard,VideoCard,MediaCard,ReceiptCard:WithTitle/WithSubtitle/WithText/WithTap,AddImage,AddMedia,AddButton/AddButtons, and receipt-specificWithTotal/WithTax/AddFact/AddItem. Backing collections are created on demand, so these are safe on default-constructed cards.Examples
Building a message with a card and a mention in one expression:
Suggested actions, fluently:
Mention queries:
Type checks:
Notes / scope
ToAttachment()toMediaCard/BasicCard: those two types have no defined content-type constant inContentTypes, so a standard attachment can''t be produced. They received fluent builders instead.IActivity(rather than interface members) specifically to avoid a breaking change to interface implementers.