SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Martin Konicek

  • Debugger visualizers for SharpDevelop

    In SharpDevelop 4.1 the debugger has a completely new functionality called Debugger visualizers. This post presents two new visualizers which are included in the standard release of SharpDevelop and shows how to implement your own visualizers.

    Object graph visualizer

    The Object graph visualizer is designed for debugging data structures. It presents live data structures in a program in the same way people draw data structures on a whiteboard - boxes represent instances and arrows represent references between them:

    To help debug algorithms operating on the structures, animated transitions are shown when a step is performed in the debugger. This is best explained by a video.

    Collection visualizer

    The second visualizer is designed for easier debugging of collections. Before introducing the visualizer, let's look at a familiar view of how collections are commonly being presented:

    The problem is that the tooltip does not show any useful information. To actually see anything we have to expand and collapse individual items, one by one. Could we do better? Enter the Collection visualizer:

    This view shows all the properties at once. You can select interesting properties using the ComboBox in the top right corner (selecting fewer properties makes scrolling faster).

    Adding your own visualizers

    The visualizers are extensible in the sense that you can implement your own visualizers and make them appear in the standard visualizer selector in SharpDevelop. Say we want to implement a visualizer that shows syntax highlighted XML strings:

    This is actually quite simple. We need to specify three things:

    • For which types will the visualizer be available
    • What should happen when user executes the visualizer
    • The label in the UI („Xml visualizer")  

    First we implement IVisualizerDescriptor:

    public class XmlVisualizerDescriptor : IVisualizerDescriptor
        public bool IsVisualizerAvailable(DebugType type)
            return type.FullName == typeof(string).FullName;
        public IVisualizerCommand CreateVisualizerCommand(Expression expression)
            return new XmlVisualizerCommand(expression);

    Then we implement a command that defines the behavior:

    public class XmlVisualizerCommand : ExpressionVisualizerCommand
        public XmlVisualizerCommand(Expression expression) :base(expression)   { }
        public override string ToString()
            return "Xml visualizer";  // label in the UI
        public override void Execute()
            // Our visualizer was selected.
            // We can do anything here - in this case we open a window showing the value of the variable.
            string expressionValue = this.Expression.Evaluate(WindowsDebugger.CurrentProcess).AsString();
            var window = new XmlVisualizerWindow(expressionValue);

    The XmlVisualizerWindow is just a simple WPF Window with a multiline TextBox showing the string, highlighted using the built-in syntax highlighting of AvalonEdit. The only remaining thing to do is to tell SharpDevelop about our new visualizer. This is done by adding the following into our .addin file:

    <Path name="/SharpDevelop/Services/DebuggerService/Visualizers">
        <Class class="YourNamespace.XmlVisualizerDescriptor" />

    Now SharpDevelop will offer our new visualizer for String variables and execute our code when the visualizer is selected:


    The XML Visualizer shown here is also a part of the standard release of SharpDevelop.

    Note that this functionality is not analogous to Visual Studio's debugger visualizers which work by passing serialized objects from the program to the debugger and therefore:

    • require types to be Serializable
    • cannot perform lazy loading as the whole object has to be serialized and passed at once
    • require types to be annotated with attributes

    The visualizers in SharpDevelop are currently implemented as SharpDevelop AddIns and use the debugger API, which allows for more flexibility than when passing a serialized object. This was needed to efficiently implement the Collection and Object graph visualizers. Adding also a serialization based API for simpler visualizers is a good idea for the future.

    Notes on implementation

    Implementing the Collection and Object graph visualizers was quite interesting. To achieve reasonable performance, the Collection visualizer queries only the values that are actually visible (getting values from the debugger is quite expensive as it involves interprocess communication).

    In the Object Graph visualizer it was not easy to detect shared references because the garbage collector is moving objects around in memory while the debugger is trying to determine how the graph actually looks (see David's post on debugger internals). Another challenge was how to layout the graph and draw the edges dynamically so that the nodes of the graph do not move around too wildly on every small change to the graph.

    In case you are interested to read more, I recently wrote a Master thesis about this which covers everything in depth.


    Hope you will find these features useful. In case of any issues or ideas for improvement feel free to comment on this post or drop me an email (martin.konicek at

  • New productivity features in Beta 2

    As we are releasing Beta2 today, here is an overview of new features you can already take advantage of:


    1. Context actions

    These are useful actions in the code editor which SharpDevelop offers based on context.

    Let's say I want my class to implement an interface. A pencil icon appears telling me that there is some action available:

    Let's click the pencil icon, or simply press Ctrl+T:

    Let's just click it or press Enter:

    And we get the expected result.

    Another example of context action is introduce new method. When I type a name of unknown method:

    Context action is offered (press Ctrl+T):

    Selecting it produces the expected result:

    These features were previously available in editor context menu. They are being moved from context menu to context popup. The reason is that it is much faster to access them this way.

    The Context Actions offered in the popup are extensible, so you can write addins to add your own. I wil write a blogpost about this.



    2. Menu restructuring and shorcuts

    The context menus in code editor had unnecessary submenus. They now look like this:

    The actions for the clicked symbol are on the top level. Also many items got keyboard shortcuts (these shortcuts are still subject to change), so that you can trigger e.g. Find References by one key press. Other useful new shortuts are F5 to Run/Continue debugging and Shift+F5 to End debugging.



    3. Find overrides

    Many times, you have code working with interfaces. The IInvestor in the previous screenshot might have only 1 or 2 implementations and you know which one is going to be returned from Service.GetInvestor(). If you want to see the implementation of the DecideWhatToBuy method, just press F6 for Find overrides.

    That's it, just press Enter. Note that before this feature it was quite annoying as Go to definition would just take you to the empty definition of the method in the interface.

    4. New code completion

    In short, the CodeCompletion is now searched by substring and CamelCase:

    The most exciting feature is automatic insertion of using. Notice that in the previous screenshot, we are not importing System.IO. Look what happens when we select FileStream:

    I am using this feature for a month now and it proved so much useful.

    I already blogged about this, check out this blog post.

    5. Highlight symbol

    All occurences to the symbol under caret are highlighted. This greatly improves code readability.

    I already blogged about this, check out this blog post - it also has a video.

    6. Switch on enum

    This is a small but useful feature. When typing a "switch" statement where the condition is an Enum the cases are automatically prefilled.

  • New Code Completion

     I hope you will be excited about this as much as I am. The Code Completion in SharpDevelop 4 just got two big enhancements:

    1. You can now search by substring or CamelCase (ReSharper-like):



     2. Notice that we did not import System.IO. Look what happens when we select "FileStream":


    If you have always been annoyed by having to spell class name without Code completion and then adding the using manually every time you were missing it, this is now over.

    This also works for Extension methods, but you have to press Ctrl+Space to see all available extension methods. We decided to use Ctrl+Space because always showing all extension methods could be confusing.

    Notice that we are not importing System.Linq:

    After typing '(', the using is again added automatically:

    Happy coding


  • Gsoc 2010 - ReSharper for SharpDevelop


    my gsoc project for this year is all about your productivity. I have been thinking what slows me down most when coding and reading code in SharpDevelop, and I would like to improve this.

    I will be working on a series of small features (ReSharper-like, but not only) which will make everyday work with SharpDevelop faster.

    The first feature is variable highlighting in the editor


    All occurences of the symbol under cursor are highlighted, which improves code readability.

    See the video. So far I got very positive feedback, you can try it yourself.


    Next planned features are:

    • ReSharper like context-aware tooltips, accessible from keyboard - what ReSharper features do you like the most?
    • Better keyboard usability (shortcut for 'Find references' etc.)
    • Snippet variable name prediction (ReSharper like)
    • Better and faster code navigation: go to to method implementation from interface, go to derived class by in-place context menu showing derived classes
    • CodeCompletion shows all classes from all referenced projects and automatically inludes 'using' if needed (already done)
    • In-place rename
    • Auto-implement IDisposable
    • Improve refactorings (if there is time): change signature

    If you ever missed any feature which would save your time, please comment this blogpost. If it is good, I will implement it.


    Cheers and happy coding


  • New debugger features implemented during #d^3

    During SharpDevelop developer days 2009 we implemented new debugger features to appear in SharpDevelop 4:

    Debugger tooltips for IEnumerable

     Debugger tooltips for IEnumerable

    The individual items of IEnumerable can be expanded normally.


    Text visualizer

    There is a new visualizer chooser in debugger tooltips.

    Choose visualizer from debugger tooltips

    For string values, Text and XML visualizers are available. Choosing "Text visualizer" shows a window:

     Text visualizer


    XML visualizer

    XML visualizer uses AvalonEdit to display syntax-highlighted xml. Folding (= node expanding/collapsing) and auto indentation will be implemented.

    XML visualizer

  • Debugger visualizers - a Google summer of code project


    my name is Martin Konicek and starting this summer, I will be trying to make your debugging experience in SharpDevelop even better. This blog will be about my project for Google summer of code 2009 - Debugger visualizers. The exciting part is that I'll be working on features that are not present in any IDE today.


    The idea is to introduce new ways to let you observe the state of the program during debugging. For me, by far the most used debugger feature are the tooltips. The problem with tooltips is they never show you the data structure "as a whole". Here we have two objects having a reference to each other:

     Tooltips are not perfect

    As we can see, the tooltips can be expanded forever, even if we have only two objects forming a loop - there is no easy was to tell this information just from the tooltips. Long ago, I was thinking how gain more insight - what about displaying the objects in memory and references between them as an oriented graph, updating live when stepping in the debugger? I wrote it as a hobby project, which gave me important lessons how not to do that.


    Object graph visualizer

    I found out that SharpDevelop team had similar idea for Google summer of code, great! I applied, researched and wrote a prototype, which I sent to David Srbecky, the author of SharpDevelop debugger and my mentor. The prototype looked like this:

    Object graph visualizer prototype


    In the picture, the visualizer (right) shows all objects that can be reached from variable "a" in the program being debugged (left).

    There is one more visualizer that is totally missing in today's IDEs in my opinion, and will be implemented. More about that next time.


    I'm 23, from the Czech Republic, currently studying CS at Charles University in the beautiful city of Prague. I think .NET is great, I have used it as my primary platform for a couple of years now. I'm teaching basics of programming to freshmen at our university - I recommend this to everyone, it's a great experience. I have a personal programming blog here.

    Stay tuned for updates..

Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this ( email address.