Add OpenDialogData and SubmitData convenience wrappers & .NET 8 Compat#410
Add OpenDialogData and SubmitData convenience wrappers & .NET 8 Compat#410
Conversation
53ee5ab to
f7cc0ef
Compare
There was a problem hiding this comment.
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
OpenDialogDataandSubmitDatautility types (both extendSubmitActionData) to standardize reserved routing fields and hide Teams protocol details. - Updated
Samples.DialogsandSamples.Cardsto use these new wrappers and to route dialog fetches viadialog_id. - Regenerated
Libraries/Microsoft.Teams.Cards/Core.csto replaceparams IList<T>withparams T[], addIList<T>overloads, and add parameterless constructors forSystem.Text.Jsondeserialization.
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_idis an identifier, but the local variable/log message still call itdialogType/"Dialog type". Renaming this todialogId(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.
There was a problem hiding this comment.
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 thedialog_idvalue used for routing, not a “type”. Renaming it (e.g., todialogId) 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.
There was a problem hiding this comment.
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_idis now user-controlled input, but it’s logged without sanitization. To avoid log injection (newlines/control chars), run it throughSanitizeForLog(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.
dclaux
left a comment
There was a problem hiding this comment.
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)
d65968d to
27fc564
Compare
@dclaux 100%. These helpers are just to simplify authoring, not intended for round-trip. |
27fc564 to
285e69c
Compare
There was a problem hiding this comment.
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.
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>
285e69c to
15dab9d
Compare
Summary
OpenDialogDataclass that extendsSubmitActionDataand abstracts away themsteams: { type: 'task/fetch' }protocol detail for opening dialogs. Takes adialogIdand optional extra data.SubmitDataclass that extendsSubmitActionDatawith a convenience constructor accepting anactionidentifier for handler routing. Aligns with web formactionattribute.dialog_id(the reserved field set byOpenDialogData) instead ofopendialogtype.params IList<T>replaced withparams T[]for .NET 8 compatibility,IList<T>overloads added for backward compat, parameterless constructors added for System.Text.Json deserialization.Note: Identifier-based handler routing is not included in this PR and will be scoped separately.
Test plan
🤖 Generated with Claude Code