samc
Topic Author
Posts: 26
Joined: 21 Aug 2019, 19:22

Debugging advice

19 Mar 2021, 18:40

Any debugging tips from Noesis pros?

Since the engine is pretty opaque, I was trying to think of ways to add more logging. I was thinking of adding a new action, "Log Action", but it isn't clear from reading the docs that I'm even able to do this. Has anyone else tried this?

I see that many of the other actions are actually implemented in Noesis in C#, so I was also just considering adding logging to all of them. This would also be helpful, but pretty spammy vs. just a single "log" action, so I'd have to filter through everything to find the logs I actually cared about.

Any other suggestions for debugging? Especially storyboards?

thanks,
sam
 
User avatar
sfernandez
Site Admin
Posts: 2109
Joined: 22 Dec 2011, 19:20

Re: Debugging advice

22 Mar 2021, 10:11

Hi Sam,

All the interactivity triggers and actions are implemented in C# with source code available, so you can modify anything you need. But as you said it would be better if you just write your own action by inheriting from TriggerAction or TargetedTriggerAction.

The Inspector is very useful for debugging as you can check the values of all the properties of any element in the UI tree and see where the value comes from: animation, bindings, styles...

Sometimes I find convenient to add some debug TextBlocks with bindings that can serve as on screen logging.

Will be great to hear what other users are doing, and how can we improve on this aspect.
 
User avatar
sfernandez
Site Admin
Posts: 2109
Joined: 22 Dec 2011, 19:20

Re: Debugging advice

22 Mar 2021, 12:32

Just as an example of a possible LogAction for Unity:
public class LogAction : NoesisApp.TriggerAction<UIElement>
{
    public string Message
    {
        get { return (string)GetValue(MessageProperty); }
        set { SetValue(MessageProperty, value); }
    }

    public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
        "Message", typeof(string), typeof(LogAction), new PropertyMetadata(string.Empty));

    protected override void Invoke(object parameter)
    {
        UnityEngine.Debug.Log(Message);
    }
}
<ei:DataTrigger Binding="{Binding Active}" Value="True">
  <local:LogAction Message="This message will be logged to Unity console"/>
</ei:DataTrigger>
 
User avatar
ai_enabled
Posts: 222
Joined: 18 Jul 2013, 05:28
Contact:

Re: Debugging advice

22 Mar 2021, 16:13

Hello!
If you want to have more details from NoesisGUI you can subscribe to its logging API (e.g. in C# SDK you can use Noesis.Log.SetLogCallback method). It produces plenty of information such as XAML loading events, binding errors, etc. If you have a full source code license for NoesisGUI you can expand its C++ code to add more logging and it will propagate via the logging callback to your application.

But what is the purpose of the extra logging in your case? To help investigate the issues in bug reports? For testing during development?
I have over a decade of experience with WPF and using NoesisGUI successfully since 2013. In my case, there was never a need to produce a verbose log about every action performed by WPF/NoesisGUI. Our logs for bug reports contain plenty of hand-written application-level logging to help us locate the issue. We can understand perfectly what was going on before the issue happened—unlike some generic logging about UI clicks/actions which would not be helpful (at least not helpful without manual application-level logs). I would also recommend using MVVM approach whenever possible as it produces the most simple code that is fairly easy to write/read/debug—unlike spaghetti code that often appears when trying to write code in codebehind.
For development, I'm usually attaching with a debugger instead of enabling low-severity logging or writing extra logging code on the application level. Though with MVVM approach I rarely need a debugger! The application is composed of plenty of small single-purpose user controls and view models, so if one component fails it's obvious what doesn't work as intended.

Regards!
AtomicTorch Studio Pte. Ltd. http://atomictorch.com

Who is online

Users browsing this forum: Bing [Bot] and 2 guests