SharpDevelop Community

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

Siegfried Pammer

  • Customizing "Pause on handled exceptions" in SharpDevelop 5

    Debugging exceptions in async methods can be quite difficult as exceptions are automatically caught and rethrown once the Task finishes executing. This leads to the problem that you end up with a stack trace missing important information about where and why the exception was thrown.

    A possible solution to this is to simply let the debugger break on any exception that is thrown in your code, even if it's handled later on. Now, that's nothing new. The "Pause on handled exceptions" feature was introduced in SharpDevelop 4. The news is that you can choose which exceptions you want to break on and which you want to ignore:

    You can add any exception you either want to break on or want to ignore. The example shown above simply means: Break on any exception derived from System.Exception, that is, every exception except System.OperationCanceledException (and any exceptions derived from OperationCanceledException).

    But, if you don't want to enter all the exceptions manually, you can ignore them while debugging a program:

    Just uncheck the box and click continue. The debugger will never break on a handled exception of that type again. Of course, you can re-enable ignored exceptions by editing the list at any time.

  • ILSpy/Debugger Integration in SharpDevelop 5

    In one of the previous posts, Andreas introduced the new features of the class browser. In addition to browsing any .NET assembly inside of SharpDevelop and combining the power of ILSpy with SharpDevelop, we added special debugging support as well! This is the good news after we removed the debugging support from ILSpy some time ago.

    Similar to the Solution node in the class browser, we added a node that represents the process currently being debugged. You can browse a loaded module and open/decompile a method, just like you would do in ILSpy.

    When stepping through your code, you can step into methods without source (for example the .NET framework, Nuget packages, and so on). You can add a breakpoint at the lines that you are interested in.

     Once execution arrives at that point, you can step through it, evaluate expressions, set additional breakpoints and so on.

    Another feature we are currently working on is to debug executables (ie you don't even have source code for the .exe):

    You can select any .NET exe and it will be started by SharpDevelop with the debugger attached. You then can examine it in full depth.

    Hope you like these new features, if you have any questions or find any bugs, please use the forums.

  • SharpDevelop 4.4 and the .NET Framework 4.5.1 RC Developer Pack

    Simply take a look at the following comparison screenshot:

    SharpDevelop 4.4 now supports displaying documentation for the recent .NET framework 4.5 and 4.5.1 upgrades in code completion. You can get the Developer Pack from here. SharpDevelop 4.4 nightly builds are available here.


    NOTE: These changes are not yet merged into SharpDevelop 5.0. (Read: SharpDevelop 5.0 doesn't yet support the documentation for .NET 4.5 and 4.5.1.)

  • New in SharpDevelop 5: Go To Definition on Partial Types (Improved)

    Especially when working with XAML files and C# code-behind files, I found it annoying that SharpDevelop always landed me in the XAML part of a class when Ctrl+clicking on the type name of a window or control. Now SharpDevelop will display a popup when there are more parts you could want to jump to:

  • New in SharpDevelop 5: Group Search Results by Project or Project and File

    Sometimes it is useful to only see search results from specific projects. It makes it easier to refactor only a part of a solution without having to pay attention to not edit files in the wrong projects. Hence I implemented two new grouping modes in the search results pad:

    Group by project:

    Group by project and file creates two levels of tree nodes:

  • SharpDevelop 4.3.1: A Little Support for Markdown

    The Markdown syntax for formatting text recently gained more and more visibility and is used especially on StackExchange, GitHub and so on. Hence we added simple highlighting support for Markdown.

    Here's an example of what it currently looks like in SharpDevelop:

    As you can see, it is far from complete, but it is a good start.

    If you have a weekend to spare and want to help out, you could help us with one of the following features:

    • Code completion
    • Folding
    • Extended highlighting
    • Live preview view content

    (We won't do those any time soon, because there are more important things to be done in SharpDevelop 5)

  • AvalonEdit 4.3: Input Method Editor support

    Good news for all Chinese, Japanese and Korean users of AvalonEdit (and others using complex script). Recently we were able to add integrated support for IMEs (Input Method Editors) in the latest version of AvalonEdit.

    Before: The IME is floating outside of the text area.

    After: The IME is directly integrated into the editor. In the first part you can see Korean IME, in the second one Japanese IME in Hiragana Mode.

    Tested on: Windows 7

    In the development team we don't use IME and we couldn't test it very well, due to a lack of knowledge of the specific languages. (I only know a little Korean and even less Japanese.) So if you run into a bug while using it, please report it on the forums.

  • SharpDevelop 4.2: Debugging C# 5 async methods

    As Chris already announced in a previous blog post, SharpDevelop 4.2 and later will support targeting .NET 4.5. One of the interesting new features in .NET 4.5/C# 5 is async. If you have already tried debugging an async method, you will have noticed, that SharpDevelop's debugger is unable to evaluate any local variables.

    In short this is because async is - similar to iterator blocks (yield return) - implemented as state machine in a compiler-generated struct. So the debugger has to find the correct location (i.e. compiler-generated code) where all the local variable's values are stored.

    In the most recent nightly builds of SharpDevelop 4.2 Beta 2 (starting with build, we've applied the necessary plumbing to make it work. But see for yourself:

  • Project Behaviors - Extensibility in the Project System

    With the upcoming release of SharpDevelop 4.2, you get support for ASP.NET MVC projects based on IIS and IIS Express. We also want to give you debugging support. However this required some changes in our project system, because web development usually involves a web server and the IDE attaches its debugger to the web server when the project is run. This is fundamentally different from normal projects.

    Another point is that projects consist of different "project types". For example a WPF project is usually C# + WPF or VB + WPF. An ASP.NET MVC project even consists of three parts: C#, web and MVC.

    The Solution

    Visual Studio solves this by inserting different project type GUIDs into the project file. Depending on the GUIDs it opens the project file with a different handler. While this approach is a good idea, its implementation in Visual Studio requires the project file to be read two times. First it is opened and scanned for the project type GUIDs and then opened again with an XML parser and finally loaded completely. (Source: [1])

    So each project type can have various sub-types defined by GUIDs. Scala implements such type compositions through mixins. In fact we would need something like this (pseudo syntax):

    var mvcProject = new CSharpProject() with WebSupport(), MVCSupport();

    Of course this is not possible in C#. So we borrowed this concept and implemented it through project behavior chains, as described below:

    In SharpDevelop we first load the project file into an IProject container. Which container to use is defined by the file extension. So there is a CSharpProject (.csproj), VBProject (.vbproj) or FSharpProject (.fsproj) and so on. After the container is initialized and the file has been loaded, we look for the project type GUIDs and then load all the project behaviors that apply to the different GUIDs.

    A project behavior is a set of virtual methods that can be overridden to alter certain behavior of the project (for example Start, which starts the project with or without debugger). Project behaviors are chained together in the order they appear in the AddIn Tree. If a project behavior does not want to handle a certain call, it is passed onto the next project behavior. At the end of the chain there is the default project behavior which implements the defaults for each project type.

    This change allows AddIns to implement different handlers for different projects without modifying the whole project system and/or the debugger.



  • SharpDevelop 4.2: Code Quality Analysis - Dependency Matrix

    In SharpDevelop 4.2 Beta we added a new feature which was partially developed by Tomas Linhart during GSoC 2010. Because it was never finished it took us some time to complete it after GSoC. One of the biggest changes after GSoC was the rewrite of the core engine. The engine now uses the new NRefactory 5 Type System in combination with Mono.Cecil.

    It is nearly done now, only little changes to the UI will be made until the final release of SharpDevelop 4.2.

    To launch the addin, simply select Analysis > Analyze Code Quality from the main menu. First you have to select a set of assemblies from the file system. After the analyzer completes the matrix above will be shown. The colours are  quite simple:

    • Green: left uses top
    • Blue: left is used by top
    • Turquoise: left uses and is used by top

    The numbers in the cells tell you how many dependencies there are from left to top or vice versa.

    For example this code:

    string M(string a) { return a.ToLower(); }

    It has three usages of the type System.String and one usage of the method System.String.ToLower.

    But in our matrix we show only one dependency on System.String, otherwise the numbers would be too noisy. This shows that there is one class from mscorlib involved in the method M.

    This is only a preview and I hope it is useful to you. If you have any suggestions or find bugs, please feel free to post a comment below or on the forums.


  • Output pad: Ported to WPF and added search functionality

    While hunting a bug related to Windows Forms, we decided to move the output pad to WPF. It now uses AvalonEdit instead of a textbox and we added support for file hyperlinks (C#, VB and NUnit); additionally you can now search through debug output by pressing Ctrl+F while the output pad is focused.

  • AvalonEdit 4.2: Virtual Space

    In recent builds of SharpDevelop 4.2 and AvalonEdit I implemented the "Virtual Space" feature. This feature allows you to place the caret after the end of the line. It was necessary to properly implement rectangle selection.

    You can enable it in the TextEditor by setting EnableVirtualSpace = true or in the SharpDevelop options. When a rectangle selection is active virtual space is enabled implicitly.

    For a detailed overview/explanation see the following:

    I hope you find this useful. If you find any bugs or have a suggestion, please leave a comment!

  • SharpDevelop 4.2: Search and Replace refurbished

    The Search and Replace engine used in SharpDevelop had a bad architecture. The concept of IDocumentIterator (for a number of documents) and ITextIterator (for a single document) leads to problems when doing manual "Find next" over multiple documents. It leads code duplication and there are lots of hacks to circumvent all sorts of bugs.

    In the most recent alpha builds of SharpDevelop 4.2 the core parts of the Search and Replace engine were rewritten. While rewriting the code I wanted to get rid of code duplication, bugs, special cases and improve performance of the search engine. In a first step I removed all the existing engine code.

    Choosing a search algorithm

    There are lots of debates on .NET string search algorithm on the net. Some propose to use IndexOf, because it seems faster than Regex, others suggest to implement your own FastIndexOf. I choose to implement search using the Regex classes in the BCL for several reasons:

    1. It is easier to maintain because it is less code. Additionally the Regex classes are well tested in contrast to a custom IndexOf.
    2. There are multiple search modes: Normal, Wildcards and Regex. For regex, of course, we had to use the Regex classes. Wildcards are easier to translate to regex and plain text search is fast enough (if not faster in some cases), when using compiled regex.
    3. Features like "Ignore case" and "Match whole words" are implemented with Regex easily. "Match whole words" is simply \bsearchTerm\b.

    Using regex has helped to get rid of code duplication, bugs and special cases. I hope you agree with me and see the benefits of simplicity in contrast to micro and rare-case optimization.

    SearchPanel: Single file search - Integrated into the AvalonEdit text editor

    In AvalonEdit 4.2 Ctrl+F functionality has been directly built into the editor. The normal Search and Replace dialog has been moved to Ctrl+Shift+F. Incremental and Quick find were removed, because the SearchPanel is a very powerful replacement.

    As you can see it offers some basic search options. You can use F3 to jump to the next match and Shift+F3 to move to the previous match.The SearchPanel will soon be integrated into ILSpy to allow full-text search in currently decompiled code.

    Improving performance and usability of Find all in multiple files

    One of the weaknesses of Find all in SharpDevelop was its speed on the one hand and on the other hand, it was locking up SharpDevelop so the user had to wait for Find all to complete.

    During the redesign of the search engine, we also focused on making it thread-safe. This requires to create a list of files to search through before doing the actual search. This causes some neglectable delay and overhead. The only case in which this would turn out really bad, is a recursive directory search starting from C:\ using *.* as file mask. But this is certainly not a common scenario when working with an IDE.

    The good news is, you can continue working while waiting for the search to complete. Please keep in mind that all changes you make to documents while Find all is active are not guaranteed to be recognized, depending on when the background thread processes the file.

    Another good news for all those of you with multi-core CPUs: SharpDevelop 4.2 will process multiple files in parallel and display all results in real-time. So you can work with the first results while the remaining files are processed. This is implemented using the IObservable<T> and IObserver<T> interfaces.

    These are the key features of the new search engine. I hope you like it. If you have any suggestions, please leave a comment.

  • SharpDevelop 4.2: Reimplemented "Create properties"

    One of the features still missing after "Alt+Ins" was removed, "Create properties" was reimplemented and added to the recent builds of SharpDevelop 4.2 (master branch).

    It can be reached by selecting "Create properties" from the refactoring main menu, or by typing propall and pressing tab in the editor (C# only):

    It will insert a small dialog at the caret position:

    You can select all the fields you want to create properties for. As you can see there are some options, you can choose whether to generate the setter of a property. Additionally you can choose to implement INotifyPropertyChanged. It will implement the interface, if it has not been implemented yet, and will add an OnPropertyChanged method. A call to OnPropertyChanged will be inserted into each property setter:

    I hope you like the return of this feature. Leave comments if you have any suggestions or problems!

  • Tip No. 1: Ctrl+W

    Even as core developers of SharpDevelop we sometimes stumble across features in our own product, we did not know about before. Hence we decided to create a SharpDevelop Tips&Tricks section on our blog(s), to let you know all the cool features you can use to speed up your work. Today I want to start with something simple.


    It often happens that you want to select of the code, whole methods or statements, or even (parts of) expressions. Of course you can do that by using the mouse or use Shift + the arrow keys, but it feels very clumsy and is inaccurate and error-prone.


    To avoid this a small hidden feature comes in very handy: Control + W. It is simple to use: Place the caret (the "keyboard cursor") somewhere inside of a piece of code you want to select.

    Then hit Ctrl+W and the innermost expression, statement or member will be selected. Hit Ctrl+W again to extend the selection. You can repeat this as many times as you want; you will end up having selected the whole file.


    Imagine how this feature can be used in conjunction with other features like surround with (Ctrl+J) or extract method. In the future there could be a Introduce variable/constant refactoring, which extracts an expression into a variable/constant initializer.

    Quick note: currently it is not possible to undo or shrink the selection. Would you like to have something like that too? If so, which keyboard shortcut would you choose to make it easy to use?

    Update: Shrink selection was added as Ctrl+Shift+W in SharpDevelop 4.2 alpha builds. Thank you for your feedback.

    Version Information

    This feature is available in SharpDevelop 4.0 and newer.

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