How to Debug Transformations?

kentico guy asked on March 27, 2020 18:00

I am getting some unexpected and unreliable results from a really whacked out transformation that someone else designed. Is there any way to debug a transformation? I'd like to step through the K# as if it were C#. The transformation looks like it's getting looped when the page loads, so stepping through the macro methods that it's invoking seems unreliable.

Recent Answers

Brenden Kehren answered on March 27, 2020 18:06

In System > Virtual Objects you can click the Test Virtual Objects to see if they will pass/build properly. They may not give you the details as Visual Studio debugging but it will give you something. Check the event log as well.

Also if your transformation is that complex, you may want to create a custom transformation method for it instead. Transformations should be simple in nature with NOT a lot of logic built into it.

2 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 27, 2020 18:41

if it is K# there is no debug except the good old console output. K# supports console output using the print(<expressions>) or println(<expressions>) syntax. This is useful if you want to output current values during cycle iterations without the need to declare a variable where values would be stored in each iteration and returned in the end.

Console output has higher priority than standard output of an expression, as you can see in the example below.

// returns "2345678910", the "ignore" string at the end is ignored as console output has higher priority
{% z = 1; while (z < 10) {print(++z)}; "ignored" %}
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.