This tutorial version is obsolete - jump to the newest one

Object Properties

Learn how to record complex user-defined object's properties

Estimated reading time: 2 mins

Last edited: 18 Dec 2019

Due to high impact on memory usage, on default RevDeBug does not record all of the objects. But you can enable this functionality with the use of RevDeBug API. It will allow you to record user-defined (i.e. with source code available) complex object.

First you need to add RevDeBug to your application. To do this, follow this chapter about API installation.

Example - recording complex objects

The idea behind complex objects’ recording is very simple: you just need to call RevDeBug.Api.CrashRecorder.Api.ComplexObject on that object and all its properties will be automatically inspected and stored in the recording.

Here is an example made on our Demo application. In the MainWindow() of this application we will create a brush, and try to get it’s property value with the use of RevDeBug API.

MainWindow.xaml.cs

public MainWindow()
{
  InitializeComponent(); 
  var converter = new BrushConverter();
  RdbRedBrush = (Brush)converter.ConvertFromString("#b01f1c");
  RevDeBug.Api.CrashRecorder.Api.ComplexObject(RdbRedBrush);
}
  

To check, if this code worked, you can open it in Visual Studio with RevDeBug IDE Extension installed. If you run it, and open the recording, you should get a similar result: Value prompts - values overlayed on code

It is possible to control how a complex object would be serialized while being recorded by RevDeBug. It may be accomplished by attaching information about RevDeBug Display methods within the application. Each RevDeBug Display method should be parameterless, and it should return a string representation of complex object. There are no limitations for the contents of the returned string, although user should consider both space that might be required and real-time slot needed for processing and serialization. RevDebug Display method is executed each time an object is stored.

To attach RevDeBug Display method, user must create a new file with .rdbdisplay extension, that should be located in a .NET project. The easiest way to do this is by creating a new text file in a project, and then changing its name and extension. This file’s Build action must be set to AdditionalFiles. RdbDisplay file Each line within this file will should contain information about a single RevDeBug Display method. User must include type name with a full namespace path and name of a RevDeBug Display method that is separated with dash from type name: Starter.MainWindow-RdbString

RdbDisplay content

where MainWindow is a name of the type, Starter. is full namespace path that leads to the type and RdbString is the name of an parameterless method that returns a string.

MainWindow.xaml.cs

namespace Starter
{
    public partial class MainWindow
    {
        public Brush RdbRedBrush;
        public Brush RdbGrayBrush;

        public string RdbString()
        {
            return $"{RdbRedBrush.ToString()} - {RdbGrayBrush.ToString()}";
        }
...