SharpDevelop Community

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

Christian Hornung

  • Windows.Forms Designer Project Resource Support

    As of SharpDevelop 3.0 build 3534, the integrated Windows.Forms designer supports project resources for images and icons. Especially, this means that forms generated by Visual Studio that use such resources can now be loaded and modified in SharpDevelop.

    In earlier versions of SharpDevelop, when adding an image or icon to a control the only possibility was to import an image file which was then stored in the resource file of the form. This also meant that an image was often stored in the resources multiple times, for every single control where it was used.

    In the new build, you will now see the following dialog when you click on the dots to edit an image property of a control:

    The "local resource" option in combination with the "Import" button lets you do what the earlier versions did: Import a file and store it in the resources of the form.

    The new "project resource" option, however, lets you choose a suitable image resource from any resource file in the current project that does not already belong to a form. This way, resources can be reused and maintained more efficiently.

    Adding this feature required a lot of complex coding, including creating custom code serializers and deserializers, and getting this right is sometimes more like a game of pure chance, because the internals of the forms designer in the .NET framework are documented poorly. So, please feel free to test this feature thoroughly and report any problems in the forums.

  • More Comprehensive Exception Reports for SharpDevelop

    First and foremost, we hope that you will not see the "unhandled exception" dialog box of SharpDevelop often. Nevertheless I would like to shed light on some improvements in that area.

    In spite of all error reporting features of an application, the best thing users can do to help us is to describe as precisely as possible what they were doing that eventually led to the error. However, SharpDevelop 3 now also outputs some additional information that may help with fixing the bugs. As of build 3.0.0.3455, two extensions to the exception reports created by SharpDevelop are in place and working:

    The log message recorder permanently stores a number of internal log messages (currently up to 25) in a cyclic buffer. Those messages are then added to the report whenever an unhandled exception occurs. Here you can see the exception box with some log messages scrolled into view:

    Additionally, some state information is added to the report. Currently the following items are listed:

    • installed 3rd party add-ins
    • type and name of the current project
    • name and some properties of the current solution
    • active view content
    Please note that the new exception reports can contain information which you might want to keep private. For example, names of projects, files, classes, methods etc. can appear in the log messages and state information, perhaps even parts of code that has been edited. If you are concerned about privacy, you should look through the generated report and check whether it contains anything you do not want to disclose before posting it. Feel free to anonymize it as necessary, but please make sure that you do not change the "meaning" of the report - i.e. if you change a name, change all occurrences of that name equally.
  • ResourceToolkit Improvements

    The ResourceToolkit addin has gained some small improvements which will be in SharpDevelop 3.0 Beta 2.

    Since build 3252, it has been possible to select the scope for the "Find missing resource keys" operation. You can see the choices in the following screenshot:

    Clicking on one of the four possible scopes in the new submenu starts the operation. Especially developers who work on large projects benefit from this new feature because this operation used to run on the whole open solution always and that can take quite some time, by that I mean several minutes. Now it is possible to check only a single file, for instance, which will be much faster.

    The results appear in the search results panel as usual:

    Additonally, the ResourceToolkit now also supports detecting the calls to ComponentResourceManager.ApplyResources which are generated by the Windows.Forms designer using the new property reflection localization model. This means that resources used by designed forms with the new model will no longer be incorrectly listed as unused.

    Finally, I fixed some small bugs that could have caused a resource reference to be detected at positions where there is none.

  • 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

  • ResourceToolkit addin

    The ResourceToolkit addin has been added to SharpDevelop 2.1 ("Serralongue") in revision 1866.

    It is intended to be used in development of localizable applications and helps the developer with managing string resources by providing tool tips on resource keys and code completion. These features are currently working in most cases when the .NET framework resource accessing classes (System.Resources.ResourceManager or derived classes) are used. String resource access using ICSharpCode.Core ("${res:...}" or ResourceService.GetString) is also supported. The following screenshot shows the resource code completion window:

    Resource code completion window

    The documentation of the previous (discontinued) stand-alone version of this addin is still available on my website:
    http://dev.hornung.dynalias.com/
    There you can find some more detailed information especially on the exact coding requirements for the addin to detect the resource references. 

    If you already had the stand-alone version installed, and are now upgrading to a newer SharpDevelop build, you should uninstall the stand-alone version using the AddIn Manager to avoid problems and duplicate menu items. 

     

    New features

    The integrated version of the addin has some new major features that were not present in any previous version.

    First, "Find references" and "Rename" commands are now available for resource keys:

    Resource refactoring menu 

    They operate on the whole solution and can be used like the similar commands for classes, methods etc.
    "Rename" will rename all occurrences of the resource key in code, the resource key itself in the resource file and also in all localized resource files with the same name, as long as these are in the same directory as the main resource file.

    Two other new commands are available through the tools menu:

     

    These commands also operate on the whole solution. Their performance is quite bad at the moment because they need to resolve all resource references in all source code files, but I have already some ideas how to improve that.

    "Find missing resource keys" looks for resource keys that are referenced in code but cannot be found in the resource file. The results are displayed in the search results panel:

    Here I ran this command on a copy of the SharpDevelop source code (this took about 72 seconds in debug mode, by the way). The one item it has found here is not actually a missing key. The addin has found the string "${res:" as an indication of an ICSharpCode.Core resource reference, but of course it cannot find this key because it is concatenated at runtime with a variable, and so this key is reported as missing.
     

    "Find unused resource keys" looks for keys that are present in a resource file but not referenced anywhere in code. The results are displayed in a new view:

     

    Here I ran this command on the SharpDevelop solution as well.

    Note that you have to be very careful with the list you get here. The addin cannot detect all kinds of resource references, especially not ones that are outside the scope of the open solution. So this list most probably always shows some keys that are in fact used somewhere. For example, all the "Templates." keys are listed here although they are used, because the are only referenced in the external template files which the addin knows nothing about.
    Because of this problem, I plan to add some filtering capabilities to this view so that you can filter out the "false positives" more easily.

    Resource keys can be deleted directly from this view by using the context menu or the delete button in the SharpDevelop toolbar after selecting one or more rows in the list. The keys are also deleted from the localized resource files if these are in the same directory as the main resource file. 

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