SharpDevelop Community

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

Christian Hornung

Juli 2008 - Posts

  • New Windows Forms Designer Localization Model Available

    As of SharpDevelop 3.0 build 3273, support for a new localization model for the Windows.Forms designer is available.

    The localization model can now be selected on a new options page:

    The "property assignment" model has been the default in all earlier versions of SharpDevelop. When you look at the generated code for a localizable form, you can see it produces statements like this:

    For many properties of each control on the form an assignment and a resource entry is generated. As stated in the .NET SDK documentation, this model scales very poorly as the number of properties increases, especially if a lot of properties are only set to their default values.

    As of build 3273, SharpDevelop 3.0 now supports the "property reflection" model and also uses this one by default. It generates only a single line of code to apply the resource entries for each control:

    The resources.ApplyResources method uses reflection to apply all resource entries in the resource file to the corresponding properties of the control. While reflection tends to be slower at runtime, this model has the advantage that default values are not written to the resource file and thus need not be applied at runtime. So generally this model is considered faster, especially for large numbers of controls and properties with default values. Additionally, the generated resource files (and thus also the resulting assemblies) are usually smaller compared to the "property assignment" model.

    The new localization model options page also has a check box to selected whether the localization model of existing forms should be left unchanged. If this box is checked, when loading a form the designer will try to find out the existing localization model by analyzing the code and use that one. Otherwise, all forms will be converted to the selected localization model as soon as they are modified and saved.

  • Reflector AddIn Released

    The new Reflector AddIn for SharpDevelop has been released. It has been integrated into the SharpDevelop 3.0 tree in build 3249 and it is also available for download for SharpDevelop 2.2.1.

    The Reflector AddIn provides the ability to open Lutz Roeder's free .NET Reflector directly from the source code editor and position it on the selected code element.

    For those who do not already know Reflector, it is an excellent .NET assembly browser and also a disassembler and decompiler for various .NET languages. It really comes in handy when you are working with a poorly documented library, for instance.

    Decompilation example

    I recently wanted to make use of the SharpSvn library which is essentially a managed wrapper for the Subversion client API. During development I came across the following situation:

    Now there is obviously no documentation available for the GetStatus method, and I do not want to go and download the whole source code either. But I would like to know whether the "statuses" collection can be null when that method returns. So what can we do? Open Reflector. The Reflector AddIn provides that command in the refactoring context menu:

    When you select that command, Reflector will be started up automatically if it is not running. Then Reflector will load the required assembly and directly go to the selected method (of course this is also supported for classes and other types of class members):

    Now we want to see the code. Press space bar (or select "Disassemble" from the "Tools" menu). There it is:

    Now we can see that the "items" variable is always initialised and assigned to the out parameter in question within the finally block. This means that we will never get a null value.

    Of course you can also use the combo box at the top where it says "C#" in the screenshot to change the output to your favourite .NET language. Reflector currently supports C#, VB.NET, Delphi, Managed C++ , Chrome and raw IL out of the box.

    The "Open .NET Reflector" command is also available through the class and class member bookmarks on the left margin of the source code editor and also through the context menu in the class browser of SharpDevelop:

    First-time configuration

    When you use the Reflector AddIn for the first time, you have to tell it where to find Reflector. For this purpose, the following dialog will pop up:

    There you can also find the download link for Reflector in case you do not have it already. Then you have to click the Browse button and locate Reflector.exe.

    As soon as you click OK, the location is saved. This dialog will automatically reappear if the add-in can no longer find Reflector.exe at the saved location.

    Please note that SharpDevelop must have write access to the directory containing Reflector.exe because it has to copy some files there and modify the configuration of Reflector to load them automatically on startup. This is needed so that Reflector exposes a remoting service which SharpDevelop can connect to.

    More Reflector functionality

    Reflector can also list all the callers of a method, property etc. and all code elements that are in use by a certain member. This function is available through "Tools" -> "Analyze":

    Reflector itself also has its own add-in architecture and a great variety of add-ins is available. For example, there are add-ins which can draw class diagrams, sequence diagrams or dependency graphs.

    Download for SharpDevelop 2.2.1

    The Reflector AddIn for SharpDevelop 2.2.1 is available for download on my web site:
    http://dev.hornung.dynalias.com/reflector-addin-for-sharpdevelop/download.html

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