Skip to content

Add MessageExtensions.AttachmentLayout (list|grid); keep Attachment.Layout (list|carousel)#488

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/change-attachmentlayout-type-to-grid
Closed

Add MessageExtensions.AttachmentLayout (list|grid); keep Attachment.Layout (list|carousel)#488
Copilot wants to merge 3 commits into
mainfrom
copilot/change-attachmentlayout-type-to-grid

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

Splits attachment layout into two distinct types to match the wire protocol, mirroring the equivalent split in teams.ts:

  • Attachment.Layout (Activity / Message): list | carousel — unchanged
  • MessageExtensions.AttachmentLayout (MessageExtension Result): list | grid — new

Related:

The context that the rename was reverted upstream was lost in #193 and #488; this PR mirrors the final teams.ts shape rather than the reverted rename.

Changes

  • Libraries/Microsoft.Teams.Api/Attachment.cs: unchanged — Layout keeps List and Carousel (correct for Activity/Message wire format).
  • Libraries/Microsoft.Teams.Api/MessageExtensions/AttachmentLayout.cs (new): adds MessageExtensions.AttachmentLayout : StringEnum with List ("list") and Grid ("grid"), following the existing StringEnum pattern (matches Attachment.Layout and MessageExtensions.ResultType).
  • Libraries/Microsoft.Teams.Api/MessageExtensions/Result.cs: AttachmentLayout property type changed from Api.Attachment.Layout? to the new MessageExtensions.AttachmentLayout?.
  • Samples/Samples.MessageExtensions/Program.cs: updated the six AttachmentLayout = ...List assignments to reference Microsoft.Teams.Api.MessageExtensions.AttachmentLayout.List (required because Libraries/ and Samples/ build with TreatWarningsAsErrors).
  • Libraries/Microsoft.Teams.Api/Messages/Message.cs and Libraries/Microsoft.Teams.Api/Activities/Message/MessageActivity.cs are intentionally left unchanged (still use Attachment.Layout, which is correct).

Notes

This is additive at the API surface — Attachment.Layout is unchanged, and the only consumer whose property type changed (MessageExtensions.Result.AttachmentLayout) is source-compatible for the typical ... = AttachmentLayout.List usage pattern.

dotnet build and dotnet format pass on the changed files. The new AttachmentLayout.cs file follows the repo's prevailing convention of no trailing newline (enforced by dotnet format's FINALNEWLINE rule across the rest of Microsoft.Teams.Api).

Agent-Logs-Url: https://github.com/microsoft/teams.net/sessions/23017044-2ca1-46f9-9a18-5d084e4a18fc

Co-authored-by: corinagum <14900841+corinagum@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix AttachmentLayout type by replacing 'carousel' with 'grid' Change AttachmentLayout type to replace 'carousel' with 'grid' May 7, 2026
Copilot AI requested a review from corinagum May 7, 2026 20:32
@corinagum corinagum closed this May 7, 2026
@corinagum corinagum reopened this May 7, 2026
@corinagum
Copy link
Copy Markdown
Collaborator

@copilot accidental loss of context: In Microsoft.Teams.Api, AttachmentLayout needs to be TWO types, not one renamed type. Background: teams.ts attempted the rename in microsoft/teams.ts#381 (merged 2025-10-25) and then REVERTED it in microsoft/teams.ts#382 (merged 2025-10-29) once it became clear that:

  • Activity / Message layout on the wire is list | carousel
  • MessageExtension Result layout on the wire is list | grid

Current teams.ts main reflects this split — see packages/api/src/models/attachment/attachment-layout.ts ('list' | 'carousel') and packages/api/src/models/messaging-extension/messaging-extension-attachment-layout.ts ('list' | 'grid').

Mirror that split in teams.net. Specifically:

  1. Leave Libraries/Microsoft.Teams.Api/Attachment.cs Layout class unchanged — it must keep List and Carousel (for Activity/Message use). Do NOT rename Carousel to Grid.

  2. Add a new strong-enum type Microsoft.Teams.Api.MessageExtensions.AttachmentLayout with only List ("list") and Grid ("grid"), following the existing StringEnum pattern used elsewhere (e.g., the existing Attachment.Layout). Place it under Libraries/Microsoft.Teams.Api/MessageExtensions/ alongside Attachment.cs (which already extends Api.Attachment — same parallel-type pattern applies here).

  3. Change Libraries/Microsoft.Teams.Api/MessageExtensions/Result.cs:45 from Api.Attachment.Layout? to the new MessageExtensions.AttachmentLayout?.

  4. Do NOT touch:

    • Libraries/Microsoft.Teams.Api/Messages/Message.cs (still uses Attachment.Layout — correct)
    • Libraries/Microsoft.Teams.Api/Activities/Message/MessageActivity.cs (still uses Attachment.Layout — correct)
    • anything under core/
    • samples or tests unless required by step 3
  5. Run dotnet build and dotnet format before pushing. Ensure the new file ends with a trailing newline.

This is a NON-breaking change (the new type is additive; Result.AttachmentLayout's assignable values were already constrained to list/grid in practice, and the property type on a JSON-serialized class swap is source-compatible for typical usage where callers passed Attachment.Layout.List).

In the PR description, link both microsoft/teams.ts#381 and microsoft/teams.ts#382, and explicitly note that #381 was reverted — this is the context that was lost in #193 and #488.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 7, 2026

@copilot accidental loss of context: In Microsoft.Teams.Api, AttachmentLayout needs to be TWO types, not one renamed type. Background: teams.ts attempted the rename in microsoft/teams.ts#381 (merged ...

Done in 3bccf7d. Reverted Attachment.Layout (keeps List/Carousel for Activity/Message), added Microsoft.Teams.Api.MessageExtensions.AttachmentLayout (List/Grid) following the existing StringEnum pattern, and switched MessageExtensions/Result.cs to use the new type. Also updated Samples/Samples.MessageExtensions/Program.cs (required for the build under TreatWarningsAsErrors). PR description now links both microsoft/teams.ts#381 and microsoft/teams.ts#382 with a note that #381 was reverted. dotnet build and dotnet format pass on the changed files.

Note on the trailing-newline guidance: the repo's dotnet format rule is "no final newline" (matches existing files like Attachment.cs), so I matched that convention to keep dotnet format clean.

Copilot AI changed the title Change AttachmentLayout type to replace 'carousel' with 'grid' Add MessageExtensions.AttachmentLayout (list|grid); keep Attachment.Layout (list|carousel) May 7, 2026
@corinagum corinagum closed this May 13, 2026
@corinagum corinagum deleted the copilot/change-attachmentlayout-type-to-grid branch May 13, 2026 18:49
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.

Change AttachmentLayout type to replace 'carousel' with correct value: 'grid'

2 participants