Archive for January, 2008

Published by breki on 31 Jan 2008

Generating WSDL documentation as part of the NAnt build

WSDLs are not very readable, so I wanted to have some sort of developer-friendly documentation for web services as part of our CI build. I found a simple but effective solution: WSDL viewer (by Tomi Vanek), which is an XSLT transformation file that produces nice HTML documentation.

I had to create a custom NAnt task for XSLT transformations since <style> task failed when I tried to do transformations using the WSDL viewer XSLT (it was complaining about some XML elements not being declared):

    <script language="C#" prefix="Brejc.NAntTasks.">
        <code>
            <![CDATA[
   [TaskName("xslt")]
   public class XsltTask : Task
   {
       [TaskAttribute ("inputfile", Required = true)]
       public string InputFile
       {
           get { return inputFile; }
           set { inputFile = value; }
       }

       [TaskAttribute ("outputfile", Required = true)]
       public string OutputFile
       {
           get { return outputFile; }
           set { outputFile = value; }
       }

       [TaskAttribute ("xsltfile", Required = true)]
       public string XsltFile
       {
           get { return xsltFile; }
           set { xsltFile = value; }
       }

       protected override void ExecuteTask ()
       {
           XsltSettings xsltSettings = new XsltSettings (true, true);
           XmlDocument xsltDoc = new XmlDocument();
           xsltDoc.Load (xsltFile);

           XmlUrlResolver resolver = new XmlUrlResolver ();
           XslCompiledTransform transform = new XslCompiledTransform (true);
           transform.Load (xsltDoc, xsltSettings, resolver);

           using (Stream inputStream = File.Open (inputFile, FileMode.Open, FileAccess.Read))
           {
               XmlReader reader = XmlReader.Create (inputStream);
               using (XmlWriter writer = XmlWriter.Create (outputFile))
                   transform.Transform (reader, writer);
           }
       }

       private string inputFile;
       private string outputFile;
       private string xsltFile;
   }
             ]]>
        </code>
        <references>
            <include name="System.Xml.dll"></include>
        </references>
        <imports>
            <import namespace="System.IO"></import>
            <import namespace="System.Xml"></import>
            <import namespace="System.Xml.Xsl"></import>
        </imports>
    </script>

Now all you need is to use this task to create the documentation:

    <target name="docs.wsdl" description="generates wsdl based on the existing web services">
        <mkdir dir="doc\wsdl" unless="${directory::exists(’doc\wsdl’)}">
        <xslt inputfile="SomeWebService.wsdl">
              outputfile="doc\wsdl\SomeWebService.html"
              xsltfile="lib\WsdlViewer\wsdl-viewer.xsl"/>
    </xslt>
</mkdir></target>

Published by breki on 29 Jan 2008

C# Source Code Search Engines For Internal Use

I work on a lot of different projects, both in the company I work for and in my spare time. A lot of code has been produced during that time and I constantly find myself searching for that “I remember I once wrote something like this” code. Google helps, but its search engine is not specialized for C# code and I sometimes have to do a lot of searching before finding a snippet that is perfect for my needs. Snippets in VisualStudio are helpful too, but I use them mostly for really repetitive code which merits taking time to write the snippet.

So I started to look for a search engine that would be able to go through my C# source code (and possibly source code repositories like SVN) and offer more developer-oriented search capabilities (like, for example, searching for all classes that implement a certain interface).

Desktop Search

The first thing popping up in my mind was using general desktop search engines (like Google Desktop or similar). In fact I used this approach few years ago when I played around with desktop search engines on my laptop. The problem with general search engines is the fact that they are too general: when you search for code using general search, all kinds of unrelated results pop up. And besides, installing Google Desktop just to search for my source code is a bit of an overkill for me.

Specialized Search Engines

My first stop was Koders Pro. This is a professional solution provided by Koders, an Internet source code search engine which indexes open source projects. I tried Koders Pro beta version just before it went to market and I liked it. It offers most of the features I was looking for. I liked the fact that it knows how to connect to various code versioning systems like SVN. What I didn’t like is the fact that you have to sign up online on Koders website in order to access your company’s internal search site. I like to have those things separated: what I do on my (or my company’s) private network is my own business, thank you (looks like someone else agrees with me).

Open Source Solutions

But since I wanted to have the search capability available not only on projects I work on professionally, but also for my own personal stuff, I was looking for a free (or not too expensive) preferably open source solution. So I started investigating (more or less googling).

I found a very interesting article called Using Lucene to Search Java Source Code. As the name says, it describes how to implement a search engine for Java source code using Lucene, an open source search engine library. The article describes the approach in quite a detail, I won’t go into it since this is not the purpose of this post. But anyway, it was a good point from which to start searching in a more focused way. I also found a related article, Source Code Search with Syntax-Based Heuristics, which builds upon the first article’s idea, but is more ambitious.

CS2 Project

Finally, I stumbled upon CS2 Project. This is an open source academic project created by Simone Busoli. It too uses Lucene (Lucene.Net actually) as a search engine. What I like about CS2 is its extreme simplicity. You just download the zipped binaries package, extract it somewhere on your disk, create an IIS web application for it and that’s it! No MSI installations, no extra Windows services.

When you browse to the CS2 application page, you get two text boxes: the first one is used for entering search keywords, the second one for registering paths on your disk which contain source code and should be indexed.

CS2 even offers some basic query parameters, like searching for method names, comments etc. It also supports search wildcards.

Okey, it’s not feature rich as Koders, but on the other hand the basic functionality it offers is a step in the right direction.

OpenGrok

While I was writing this post I ran into OpenGrok, an open source search engine written in Java. It supports multiple languages search, but I couldn’t find any information on whether it supports indexing of C# sources.

I will post about any new findings in the future.

Published by breki on 27 Jan 2008

Kosmos v1.9 - printing maps, inspecting elements and more…

image

After a week of quite a lot of work, a new version of Kosmos is here. The list of new features:

  • Map printing dialog (see above image): you can now print your maps in whatever scale you like. Kosmos will calculate the number of pages needed and will show a preview of the printed map. Using a PDF printer driver (like the one here) you can even export the map into a PDF file.
  • OSM objects inspection tool
  • Kosmos now understands OSM relations: in this version, relations support is limited to examining multipolygon relations and knowing how to draw polygons with holes.

There are also some bugfixes and a lot of changes in the code. This means that there are probably some new bugs too. Please report them on the Kosmos OSM talk page.

In the next version of Kosmos users will be able to set the map print area (now the whole map is printed). And some other cool stuff too.

Published by breki on 26 Jan 2008

Should I blog?

Jeremy D. Miller (author of the StructureMap) has an interesting post about good and bad stuff when you go into blogging. It is an interesting read, especially for people like me who have just started blogging. Recommended.

Published by breki on 25 Jan 2008

Friday Goodies - 25 January

Development In General

.NET Development

OpenStreetMap

General

Published by breki on 24 Jan 2008

FeedDemon: RSS reader with online sync, now free

Two weeks ago Newsgator has made its RSS feeds reading products free. I saw the posts about it but I ignored them since I already used another RSS reader (GreatNews) and was more or less happy with it. The only thing I really missed was being able to synchronize reading of feeds between the home and my workplace. This is not a problem if you use online readers, but since I’m quite demanding regarding the RSS reader user interface, I stayed with desktop applications.

Yesterday while I was reading through the latest Gizmo Richards’ Support Alert Newsletter (which I highly recommend, by the way), the FeedDemon news appeared again and I realized that not only are Newsgator’s products free, but they also offer a free registration to their online RSS reader which also serves as a synchronization point for all desktop RSS readers. So this means for example that feeds you go through at work will be marked as read and then this information will be stored on Newsgator web server. When you go back home, you won’t have to manually mark these feeds as read.

And one additional “goodie”: if you have a J2EE-enabled mobile device, Newsgator offers a beta version of Newsgator Go For J2ME. You just submit a form with your email address and will immediately receive a mail with the link to the download page of this mobile reader. I tried it on my (2-3 years old) SonyEricsson mobile phone and it works quite nicely. And off course, the synchronization feature works with mobile reader, too.

Hats off to Newsgator.

Published by breki on 24 Jan 2008

Valencia slippymap

I noticed in recent OSM Wiki changes that an OSM mapper in Valencia has generated a slippymap of his home town with some custom rendering rules. Cool.

While looking at this map I realized that Kosmos tile server needs a new setting: defining the extents of your map, so that those ugly “image not found” tiles outside the map area are not shown. I’ll add it to the “todo” list.

Published by breki on 23 Jan 2008

A new release of BrekiLabeller (1.7)

Tobias Jahn sent me a patch code for BrekiLabeller which adds some new options for generating build and revision numbers. You can now generate both build number and revision number from a file. Also, the revision number can be generated by an external tool (this is similar to SvnRevisionLabeller).

You can download the new release from the project’s sourceforge page.

Published by breki on 23 Jan 2008

GpsTrekker - my (almost) forgotten project

image

6 months ago I was busy developing GpsTrekker, an application for hiking and cycling enthusiasts. But then I joined the OpenStreetMap community and forgot about GpsTrekker. It was still in very early phase, but you could load your GPS tracks data and show various elevation contours with it (see image above).

So this is kind of a reminder post for me :). Maybe I’ll include features of GpsTrekker into the Kosmos application (or some Kosmos extension) in the (distant?) future.


Published by breki on 21 Jan 2008

Inspecting map elements in Kosmos

image

With new version of Kosmos you will be able to inspect properties of OSM elements shown on map. Element’s type, ID and its tags are displayed in a tool tip. This can come handy in combination with “Show Unused…” option when you want to determine why certain nodes or ways haven’t been covered by rendering rules.

Next »