Home > Articles > Programming > Windows Programming

Open Source .NET Development: ASpell.NET Case Study

  • Print
  • + Share This
This chapter is a simple but realistic case study of using Open Source tools in everyday development. In particular, this chapter uses ASpell, a commercial-caliber spell checking component that supports twenty-some different language dictionaries, as an example.
This chapter is from the book

Nothing you can't spell will ever work.

Will Rogers

Introduction

There are three excuses ever present in software development:

  1. We don't have time to automate the build.

  2. We'll do the documentation later.

  3. We don't have time to write tests.

I understand the importance of Time to Market and that the first release of a product is always the hardest to get out the door. However, I believe this "rush-to-market" approach to development is shortsighted and outdated. This philosophy could wind up costing you a lot more time in the end than if you spend a little time up front creating a solid development procedural atmosphere.

Chapters 4 through 7 deal directly with how to solve these problems. Writing documentation along the way is not difficult with NDoc. NAnt allows for an intuitive and solid scriptable build. Testing can actually be enjoyable with NUnit while you try to break your code with the test code you write.

This chapter is a simple but realistic case study of using Open Source tools in everyday development. To illustrate this I chose to create a new Open Source project: ASpell.NET. ASpell.NET(http://aspell-net.sourceforge.net) is a .NET wrapper around the GNU ASpell project (http://aspell.sourceforge.net). ASpell is a commercial-caliber spell checking component that supports twenty-some different language dictionaries.

ASpell.NET is not a good candidate for cross-platform support because PInvoke is not very well supported on CLIs other than Microsoft's .NET.

Thorsten Maerz has created a Win32 port of ASpell, which I will wrap in a C# component. I believe this to be a good example because it includes PInvoke calls into unmanaged code. Realistically, this process of wrapping existing functionality and making it available to managed code will probably be done for quite a while by most corporations.

For a good book on .NET Interop, see:

.NET and COM: The Complete Interoperability Guide by Adam Nathan from Sams Publishing

Adam has also created a wiki (http://www.pinvoke.net) and a Visual Studio.net add in (click the get visual studio add-in link on the Web site).

This example will check the code by using FxCop and NUnit. As we go along, we will utilize NDoc to output a useful help file for redistribution. In the end, an install will be created using MSI, and an iso file will be created using the custom mkisofs task created in Chapter 4. The iso file will then be uploaded to a server for distribution to a testing department or, depending on the extent of your testing, to customers. All this will happen automatically upon checking in code using Continuous Integration if the build succeeds (which also implies that the tests succeed).

I created ASpell.NET as a proof-of-concept to see how easy it would be to get ASpell working for .NET. ASpell.NET would make a great Web service. To eliminate the need to use pointers and the unsafe compiler option, I wrapped the ASpell dll in another C++ dll (AspellDll.dll). This allows ASpell.NET to use methods that have parameters that require pointers. So the base functionality for ASpell.NET is already there, but with no documentation or tests and without support for dictionaries other than the English dictionary. The source is available from the SourceForge project site, and you will be able to see that Log4Net also plays a part in Aspell.NET. We will use .NET's CuturalInfo to automatically detect which language dictionary to use. Finally, we will demonstrate the use in a somewhat real-world application similar to the WordPad app using #develop to create it as Windows form.

  • + Share This
  • 🔖 Save To Your Account