microsoft / microsoft/AdaptiveCards

[Rendering] AEL forEach in when .NET templating does not enumerate an object's properties

Open
#7,745 1 comment 0 reactions 1 assignee View on GitHub

@jwoo-msft is already working on this.

Since Aug 8, 2022.

Area-Templating Bug
Dominant language
C#
Stars
2k
Forks
595
Avg merge
1d 19h
Merged PRs (30d)
1

Description

Target Platforms

WPF

SDK Version

1.2.1

Application Name

Hub

Problem Description

forEach does not enumerate the properties of an object when using ,NET templating. The documentation says it should work and the card designer shows it works.

The following card works fine in the card desginer, but not in a .net application:

      {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "Container",
            "items": [
              {
                "type": "TextBlock",
                "text": "${$data}",
                "wrap": true,
                "size": "Default",
                "spacing": "None"
              }
            ],
            "$data": "${foreach(json('{\"test1\":\"object1\",\"test2\":\"object2\",\"test3\":\"object3\"}'),x,x.value)}"
          }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.2"
      }

We should see:

object1
object2
object3

But we just get the string of the AEL code.

Screenshots

No response

Card JSON
{
            "type": "AdaptiveCard",
            "body": [
              {
                "type": "Container",
                "items": [
                  {
                    "type": "TextBlock",
                    "text": "${$data}",
                    "wrap": true,
                    "size": "Default",
                    "spacing": "None"
                  }
                ],
                "$data": "${foreach(json('{\"test1\":\"object1\",\"test2\":\"object2\",\"test3\":\"object3\"}'),x,x.value)}"
              }
            ],
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "version": "1.2"
          }
Sample Code Language

No response

Sample Code

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.