Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WPF][Rendering/Templating] Renderer throws newtonsoft error #3518

Closed
DeeJayTC opened this issue Oct 10, 2019 · 10 comments
Closed

[WPF][Rendering/Templating] Renderer throws newtonsoft error #3518

DeeJayTC opened this issue Oct 10, 2019 · 10 comments

Comments

@DeeJayTC
Copy link
Contributor

Platform

What platform is your issue or question related to? (Delete other platforms).

  • .NET WPF

Author or host

Host, trying to render a card in my own app (visual studio extension)

Version of SDK

AdaptiveCards.Rendering.Wpf -> 1.2.3
AdaptiveCards.Rendering.Wpf.Xceed -> 1.2.3
AdaptiveCards.Templating -> v0.1.0-alpha1

Details

When trying to use the designer (vnext version) its all fine, designer renders the card+template correctly. Things are not working only with WPF renderer.

Keep getting this exception:
System.InvalidOperationException: 'Current error context error is different to requested error.'
during a call to : AdaptiveCard.FromJson(cardJson).Card;

This is my code:
var transformer = new AdaptiveTransformer();
var cardJson = transformer.Transform(templateData, taskData);
AdaptiveCard card = AdaptiveCard.FromJson(cardJson).Card;

Find attached card template and the card data, data-binding works fine tho.

taskCardSampleData.txt
taskCard.txt

@shalinijoshi19
Copy link
Member

Thanks for reporting this @DeeJayTC ; The currently released version of the .NET renderer does not support the templating feature at this point in time. @paulcam206 / @matthidinger can you please correct me if i am wrong? Having said that that error seems very very obscure and something we may want to investigate and address as being more actionable and useful - @almedina-ms FYI (specially to track fixing the error here)

@shalinijoshi19
Copy link
Member

Also @DeeJayTC just for our understanding, could you describe the scenario you are trying to use AdaptiveCards as well as the templating stack in? Thanks!

@DeeJayTC
Copy link
Contributor Author

Well, based on what @matthidinger said yesterday it is supported. Technically the templating just changes strings on the json itself, the render receives a final card where the templating is already done.

We're trying to render a card in a Visual Studio Extension (eg WPF Control)
Template itself is currently sitting in a json file in the repository and loaded at runtime
Data is loaded from a rest API (eg just json data)
Both template and sample json data is in the txt files.

@shalinijoshi19
Copy link
Member

Hmm so essentially you are just using the WPF renderer like you would to render a regular JSON file; Do you have the actual transformed JSON with the AdaptiveCard type element in there also ? I dont see that in the taskCardsampleData.txt file you provided nor the taskCard.txt which seems to be the pre-transformed json..In other words what is the JSON you are trying to pass in to the call to FromJson?

@DeeJayTC
Copy link
Contributor Author

Thanks for asking for that....found the issue.
While looking at the transformed data i realized that one of the urls was
"text": " [undefined](https://digitalcrew.teamwork.com/people/undefined) ( Teamwork )",
In the template i accidently used $root instead of $data.
Its working now after i changed that.

Only weird thing is that the designer on https://vnext.adaptivecards.io/designer/ renders it just fine while the WPF one throws that error.

@almedina-ms
Copy link
Contributor

Good afternoon @DeeJayTC

I'm currently trying to reproduce the error you were talking about, I'm using the WPF visualizer app removing the references to local projects and using the nuget packages you mentioned, I replaced the lines as you specified having this now

var transformer = new AdaptiveTransformer();
var cardJson = transformer.Transform(CardPayload, templateData);
AdaptiveCard card2 = AdaptiveCard.FromJson(cardJson).Card;

So far I haven't found the error and I tried to force the error by changing this line to force an error by changing root to rot

"text": "by [{$rot['creator-firstname']} {$root['creator-lastname']}]({$root.rooturl}/people/{$root['creator-id']})",

and it doesnt generate the error but I do get the undefined string in the generated view

image

@DeeJayTC
Copy link
Contributor Author

hmm maybe because $rot does not exist while $data does but has different properties to $root.
I'll try to build a small wpf app or something to reproduce this.

@almedina-ms
Copy link
Contributor

almedina-ms commented Oct 12, 2019

Hi

Sorry for the delay, I made a really simple test app for templating scenarios, it's located in this branch
user/almedina-ms/ReproNetTemplatingError

The project is under the source/dotnet/AdaptiveCards.sln solution and the project is called AdaptiveCards.Sample.WPFTemplating. It's a really simple visualizer with preloaded data and you just need to click on the "Render" button to render the card, I tried to reproduce the error with it but I wasn't able, if you can could you append the json files you managed to generate the error with?

Thank you

Alberto Medina

@ghost ghost added the no-recent-activity label Nov 29, 2019
@ghost
Copy link

ghost commented Nov 29, 2019

This issue has been automatically marked as stale because it has not had any activity for 5 days.

@RebeccaAnne RebeccaAnne added this to the Backlog milestone Jul 27, 2020
@RebeccaAnne RebeccaAnne removed this from the Backlog milestone May 6, 2021
@jonmill
Copy link
Contributor

jonmill commented Nov 18, 2021

Tracked by #1984

@jonmill jonmill closed this as completed Nov 18, 2021
@ghost ghost removed the Triage-Investigate label Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants