microsoft / microsoft/AdaptiveCards
[.NET][Templating] Whenever a null value is evaluated, a warning should be raised
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2k
- Forks
- 595
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 1
Description
Platform
- .NET WPF
Version of SDK
Templating nuget
Details
With the fix of #4574 an error was unearthed where expressions that are evaluated to null will provide a confusing user and developer experience as they won't know what may be failing.
For example, this test should fail or raise a warning but it doesn't
[TestMethod]
public void TestExceptionHandling()
{
// ${LineItem} doesn't exist in the data context provided
string jsonTemplate = @"{
""type"": ""AdaptiveCard"",
""body"": [
{
""type"": ""Container"",
""items"": [
{
""$data"": ""${LineItem}"",
""type"": ""TextBlock"",
""text"": ""${Milage}""
}
]
}
]
}";
string jsonData = @"{
""LineItems"": [
{
""Milage"": 10
},
{
""Milage"": 0
}
]
}";
AdaptiveCardTemplate transformer = new AdaptiveCardTemplate(jsonTemplate);
var context = new EvaluationContext
{
Root = jsonData
};
try
{
string cardJson = transformer.Expand(context);
Assert.Fail("There should be an exception");
}
catch (AdaptiveTemplateException e)
{
Assert.AreEqual(@"'${LineItem}' at line, '8' is malformed for '$data : ' pair", e.Message);
}
catch
{
Assert.Fail();
throw;
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AdaptiveCardTemplate.Expand and the TestExceptionHandling example in the issue, then trace how expressions such as ${LineItem} are evaluated against EvaluationContext. Add coverage for a missing or null evaluation and verify that the resulting behavior reports the problem rather than silently continuing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100