Skip to content

Add OpenDialogData and SubmitData convenience wrappers & .NET 8 Compat#410

Merged
corinagum merged 9 commits intomainfrom
cg/submit-data
Apr 7, 2026
Merged

Add OpenDialogData and SubmitData convenience wrappers & .NET 8 Compat#410
corinagum merged 9 commits intomainfrom
cg/submit-data

Conversation

@corinagum
Copy link
Copy Markdown
Contributor

@corinagum corinagum commented Apr 2, 2026

Summary

  • Adds OpenDialogData class that extends SubmitActionData and abstracts away the msteams: { type: 'task/fetch' } protocol detail for opening dialogs. Takes a dialogId and optional extra data.
  • Adds SubmitData class that extends SubmitActionData with a convenience constructor accepting an action identifier for handler routing. Aligns with web form action attribute.
  • Updates dialogs and cards samples to use the new classes.
  • Updates dialogs sample handler to read dialog_id (the reserved field set by OpenDialogData) instead of opendialogtype.
  • Regenerated Core.cs from latest codegen: params IList<T> replaced with params T[] for .NET 8 compatibility, IList<T> overloads added for backward compat, parameterless constructors added for System.Text.Json deserialization.
  • New generated types: CollabStageInvokeDataValue, OpenUrlDialogAction, PopoverAction, ProgressBar, ProgressRing, Resources, StringResource, TabInfo.
  • Matches Python SDK implementation (Improve dialog opening and card submitting semantics teams.py#222).

Note: Identifier-based handler routing is not included in this PR and will be scoped separately.

Test plan

  • Build succeeds on .NET 8 and .NET 10 (0 errors)
  • 588/588 tests pass on .NET 10
  • 11/11 cards tests pass on .NET 8
  • E2E: dialogs sample tested against Teams on .NET 8
  • E2E: cards sample tested against Teams on .NET 8

🤖 Generated with Claude Code

@corinagum corinagum changed the title Add OpenDialogData and SubmitData convenience wrappers Add OpenDialogData and SubmitData convenience wrappers & .NET 8 Compat Apr 2, 2026
@corinagum corinagum marked this pull request as ready for review April 3, 2026 19:23
Copilot AI review requested due to automatic review settings April 3, 2026 19:23
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 introduces two convenience wrappers (OpenDialogData, SubmitData) to simplify common Adaptive Cards submit payload patterns (dialog launch + action-based routing), updates the dialogs/cards samples to use them, and regenerates the Microsoft.Teams.Cards generated surface for better .NET 8 compatibility (notably replacing params IList<T> patterns).

Changes:

  • Added OpenDialogData and SubmitData utility types (both extend SubmitActionData) to standardize reserved routing fields and hide Teams protocol details.
  • Updated Samples.Dialogs and Samples.Cards to use these new wrappers and to route dialog fetches via dialog_id.
  • Regenerated Libraries/Microsoft.Teams.Cards/Core.cs to replace params IList<T> with params T[], add IList<T> overloads, and add parameterless constructors for System.Text.Json deserialization.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Samples/Samples.Dialogs/Program.cs Switch dialog routing from opendialogtype to reserved dialog_id; use OpenDialogData.
Samples/Samples.Cards/Program.cs Replace manual NonSchemaProperties["action"] payloads with SubmitData.
Libraries/Microsoft.Teams.Cards/Utilities/SubmitData.cs New wrapper for action-based routing payloads.
Libraries/Microsoft.Teams.Cards/Utilities/OpenDialogData.cs New wrapper for task/fetch dialog launch payloads.
Libraries/Microsoft.Teams.Cards/Core.cs Regenerated API surface for .NET 8 compatibility (params arrays, overloads, parameterless ctors, new generated types).
Comments suppressed due to low confidence (1)

Samples/Samples.Dialogs/Program.cs:53

  • dialog_id is an identifier, but the local variable/log message still call it dialogType/"Dialog type". Renaming this to dialogId (and updating the log message) would avoid confusion with the actual dialog content/type and make the switch cases/readability clearer.
    var dialogType = data.Value.TryGetProperty("dialog_id", out var dialogTypeElement) && dialogTypeElement.ValueKind == JsonValueKind.String
        ? dialogTypeElement.GetString()
        : null;

    context.Log.Info($"[TASK_FETCH] Dialog type: {dialogType}");


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

Comment thread Libraries/Microsoft.Teams.Cards/Core.cs Outdated
Comment thread Libraries/Microsoft.Teams.Cards/Core.cs
Comment thread Libraries/Microsoft.Teams.Cards/Utilities/SubmitData.cs
Comment thread Libraries/Microsoft.Teams.Cards/Utilities/OpenDialogData.cs
Copilot AI review requested due to automatic review settings April 3, 2026 20:07
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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

Samples/Samples.Dialogs/Program.cs:52

  • The variable name dialogType (and related log message) is now representing the dialog_id value used for routing, not a “type”. Renaming it (e.g., to dialogId) would make the handler logic and logs less confusing, especially since the switch cases are dialog IDs.
    var dialogType = data.Value.TryGetProperty("dialog_id", out var dialogTypeElement) && dialogTypeElement.ValueKind == JsonValueKind.String
        ? dialogTypeElement.GetString()
        : null;

    context.Log.Info($"[TASK_FETCH] Dialog type: {dialogType}");

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

Comment thread Libraries/Microsoft.Teams.Cards/Utilities/SubmitData.cs
Comment thread Libraries/Microsoft.Teams.Cards/Utilities/OpenDialogData.cs
Copilot AI review requested due to automatic review settings April 6, 2026 19:47
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

Samples/Samples.Dialogs/Program.cs:60

  • dialog_id is now user-controlled input, but it’s logged without sanitization. To avoid log injection (newlines/control chars), run it through SanitizeForLog (or log it as structured data if supported).
    Also consider updating the naming/message strings from “dialog type”/“Unknown dialog type” to “dialog id” to match the new field.
    var dialogType = data.Value.TryGetProperty("dialog_id", out var dialogTypeElement) && dialogTypeElement.ValueKind == JsonValueKind.String
        ? dialogTypeElement.GetString()
        : null;

    context.Log.Info($"[TASK_FETCH] Dialog type: {dialogType}");

    var response = dialogType switch
    {
        "simple_form" => CreateSimpleFormDialog(),
        "webpage_dialog" => CreateWebpageDialog(app.Configuration, context.Log),
        "multi_step_form" => CreateMultiStepFormDialog(),
        "mixed_example" => CreateMixedExampleDialog(),
        _ => new Microsoft.Teams.Api.TaskModules.Response(new Microsoft.Teams.Api.TaskModules.MessageTask("Unknown dialog type"))

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

Comment thread Libraries/Microsoft.Teams.Cards/Utilities/SubmitData.cs
dclaux
dclaux previously approved these changes Apr 6, 2026
Copy link
Copy Markdown
Member

@dclaux dclaux left a comment

Choose a reason for hiding this comment

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

Looks good. I just want to make sure I mention that while this approach works great for authoring, a card will not deserialize into those classes, it will deserialize into the raw classes provided in core.cs (which I think is fine)

rido-min
rido-min previously approved these changes Apr 6, 2026
@corinagum
Copy link
Copy Markdown
Contributor Author

corinagum commented Apr 6, 2026

Looks good. I just want to make sure I mention that while this approach works great for authoring, a card will not deserialize into those classes, it will deserialize into the raw classes provided in core.cs (which I think is fine)

@dclaux 100%. These helpers are just to simplify authoring, not intended for round-trip.

Copilot AI review requested due to automatic review settings April 6, 2026 23:56
@corinagum corinagum dismissed stale reviews from dclaux and rido-min via 285e69c April 6, 2026 23:56
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


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

corinagum and others added 8 commits April 7, 2026 10:22
Adds two utility classes to the cards package:
- OpenDialogData: abstracts away msteams/task-fetch protocol details
  for opening dialogs from Action.Submit
- SubmitData: convenience wrapper for action-based routing with a
  reserved "action" field

Updates dialogs and cards samples to use the new classes.

Routing support is not included and will be scoped separately.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
OpenDialogData sets a reserved dialog_id field instead of the
previous opendialogtype. Update the task fetch handler to match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- params IList<T> replaced with params T[] for .NET 8 compatibility
- IList<T> overloads added for backward compatibility
- Parameterless constructors added for System.Text.Json deserialization
- New types: CollabStageInvokeDataValue, OpenUrlDialogAction,
  PopoverAction, ProgressBar, ProgressRing, Resources,
  StringResource, TabInfo

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Constructor params arrays now wrapped in new List<T>() to preserve
mutability (.Add()) from the original params IList<T> pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Validates serialized shape, reserved fields, and extra data merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@corinagum corinagum merged commit 411466c into main Apr 7, 2026
7 checks passed
@corinagum corinagum deleted the cg/submit-data branch April 7, 2026 17:25
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.

4 participants