Debug visualisers are a type of IDE plugin that allows you to change the display of a variable in the various debug windows (Local Variables, Watches, Inspector, and Evaluate/Modify.) For example, the TDateTime visualiser takes the double value that represents time and instead displays that time converted to a string. You register a debug visualiser for a type, so all variables of that type, and optionally descendants of that type, go through your visualiser.
In previous versions, this type was specified by a plain string, such as ‘TComponent’, and there was no way to handle a generic type. If you registered ‘MyGeneric<T>’, the visualiser would never be called, because the concrete instantiations of that type do not use T – they might be ‘MyGeneric<Integer>’, ‘MyGeneric<TButton>’, and so forth.
In 10.2.1, we have introduced support for registering a visualiser for a generic type. Your visualizer can implement IOTADebuggerVisualizer250 as well as the prior IOTADebuggerVisualizer, where the GetSupportedType method allows you to specify that the type string is a generic:
. IOTADebuggerVisualizer250 = interface(IOTADebuggerVisualizer) ['{DC0C8D82-B783-4205-B3F4-D325BA8B3EEB}'] { Return the Index'd Type. TypeName is the type. AllDescendants indicates whether or not types descending from this type should use this visualizer as well. IsGeneric indicates whether this type is a generic type. } procedure GetSupportedType(Index: Integer; var TypeName: string; var AllDescendants: Boolean; var IsGeneric: Boolean); overload; end;
This means you can register for MyGeneric<T> and your visualiser will be called for all MyGeneric<>s. This is all generic types, ie interfaces as well as classes.
One note is that we do not yet support registering for descendants of a generic type, meaning that if you have MyDesc<T> = class(MyGeneric<T>) or MyDesc = class(MyGeneric<T>), you need to register a visualiser for MyDesc separately. This is because of some complexities in the internal evaluator.
Generics are widely used, especially for collections like dictionaries and lists, and in third-party libraries like Spring4D. We hope you will find visualiser support for generics useful!
Update: here is a code snippet demonstrating a template visualizer.