Skip to content

[Fix]: sync invoke activity Value property to base for access across type hierarchy#340

Merged
MehakBindra merged 2 commits intomainfrom
mehak/oninvokefix
Feb 26, 2026
Merged

[Fix]: sync invoke activity Value property to base for access across type hierarchy#340
MehakBindra merged 2 commits intomainfrom
mehak/oninvokefix

Conversation

@MehakBindra
Copy link
Collaborator

@MehakBindra MehakBindra commented Feb 20, 2026

Fixes #339

Refactoring of Value property implementation

  • Updated the Value property in multiple activity classes (e.g., ActionActivity, HandoffActivity, AnonQueryLinkActivity, FetchTaskActivity, QueryActivity, QueryLinkActivity, QuerySettingUrlActivity, SettingActivity, SubmitActionActivity, SearchActivity, TokenExchangeActivity, VerifyStateActivity, FetchActivity in Tabs and Tasks, and SubmitActivity in Tabs and Tasks) to use explicit getter and setter methods that interact with the base class property, ensuring correct casting and assignment. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]

Test improvements

  • Added unit tests to verify that the Value property is accessible and correctly typed both from derived activity types and from their base types for AdaptiveCards, MessageExtensions, and Tasks activities. [1] [2] [3] [4] [5] [6]

E2E Test:

teams.OnInvoke(async (context, cancellationToken) =>
{
    InvokeActivity activity = context.Activity;
    context.Log.Info("[CARD_ACTION] Card action received");

    var value = activity.Value;
    context.Log.Info($"[CARD_ACTION] Raw data: {JsonSerializer.Serialize(value)}");

    return new ActionResponse.Message("Action processed successfully") { StatusCode = 200 };
});
[CARD_ACTION] Raw data: {"action":{"type":"Action.Execute","id":null,"verb":null,"data":{"action":"submit_basic","notify":"false"}},"authentication":null,"state":null,"trigger":"manual"}

Copilot AI review requested due to automatic review settings February 20, 2026 21:27
Copy link
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 fixes a critical property shadowing bug where accessing InvokeActivity.Value through a base class reference returns null even when the derived class's Value property is populated. The fix converts auto-implemented properties using the new keyword into explicit properties with get/set accessors that sync with the base class's Value property, ensuring the value is accessible regardless of whether the activity is accessed through the derived type or base type reference.

Changes:

  • Converted 18 derived activity class Value properties from auto-properties to explicit get/set properties that sync with base.Value
  • Added comprehensive tests for 3 representative activity hierarchies (AdaptiveCards, Tasks, MessageExtensions) to verify the fix

Reviewed changes

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

Show a summary per file
File Description
Libraries/Microsoft.Teams.Api/Activities/Invokes/AdaptiveCards/ActionActivity.cs Fixed property shadowing for AdaptiveCards.ActionActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/HandoffActivity.cs Fixed property shadowing for HandoffActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/SearchActivity.cs Fixed property shadowing for SearchActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/Messages/SubmitActionActivity.cs Fixed property shadowing for Messages.SubmitActionActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/MessageExtensions/AnonQueryLinkActivity.cs Fixed property shadowing for MessageExtensions.AnonQueryLinkActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/MessageExtensions/FetchTaskActivity.cs Fixed property shadowing for MessageExtensions.FetchTaskActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/MessageExtensions/QueryActivity.cs Fixed property shadowing for MessageExtensions.QueryActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/MessageExtensions/QueryLinkActivity.cs Fixed property shadowing for MessageExtensions.QueryLinkActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/MessageExtensions/QuerySettingUrlActivity.cs Fixed property shadowing for MessageExtensions.QuerySettingUrlActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/MessageExtensions/SettingActivity.cs Fixed property shadowing for MessageExtensions.SettingActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/MessageExtensions/SubmitActionActivity.cs Fixed property shadowing for MessageExtensions.SubmitActionActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/SignIn/TokenExchangeActivity.cs Fixed property shadowing for SignIn.TokenExchangeActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/SignIn/VerifyStateActivity.cs Fixed property shadowing for SignIn.VerifyStateActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/Tabs/FetchActivity.cs Fixed property shadowing for Tabs.FetchActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/Tabs/SubmitActivity.cs Fixed property shadowing for Tabs.SubmitActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/Tasks/FetchActivity.cs Fixed property shadowing for Tasks.FetchActivity.Value
Libraries/Microsoft.Teams.Api/Activities/Invokes/Tasks/SubmitActivity.cs Fixed property shadowing for Tasks.SubmitActivity.Value
Tests/Microsoft.Teams.Api.Tests/Activities/Invokes/AdaptiveCards/AdaptiveCardsTests.cs Added tests verifying Value is accessible from both derived and base types for AdaptiveCards
Tests/Microsoft.Teams.Api.Tests/Activities/Invokes/MessageExtensions/MessageExtensionsTests.cs Added tests verifying Value is accessible from both derived and base types for MessageExtensions
Tests/Microsoft.Teams.Api.Tests/Activities/Invokes/Tasks/TasksTests.cs Added tests verifying Value is accessible from both derived and base types for Tasks

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

@MehakBindra MehakBindra requested a review from singhk97 February 20, 2026 21:41
@MehakBindra MehakBindra marked this pull request as draft February 20, 2026 21:43
@MehakBindra MehakBindra marked this pull request as ready for review February 20, 2026 21:49
Copy link
Contributor

@corinagum corinagum left a comment

Choose a reason for hiding this comment

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

Thank you ❤️

@MehakBindra MehakBindra enabled auto-merge (squash) February 26, 2026 02:32
@MehakBindra MehakBindra merged commit b0114e2 into main Feb 26, 2026
7 checks passed
@MehakBindra MehakBindra deleted the mehak/oninvokefix branch February 26, 2026 02:34
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.

InvokeActivity.Value is null due to property shadowing with new in derived classes

4 participants