Friday, 5 October 2007

Command Line Library Minor Update ( RC1)

See the RC1 release page for the means of Minor Update. The Library's tests coverage exceeds the ones created for the Test Driven Development cycle. This makes the code even more stable.
See the CodePlex home for this project, it was completely re-engineered; enjoy!

Thursday, 4 October 2007

System.Char (char) at rescue...

Sometimes is necessery to check if a string (or portion of it) contains numbers, letters or whatever else...
For the ones that "sometimes" (me included...) writes what the BCL already gives you, go to .NET documentation or MSDN online and be happy with System.Char static methods!
All the the following suggestion must be applied to a loop like that:

string s = "Hello 123 123.999 $%&! :_"; //here the input to check
foreach (char c in s)
if (char.******(c))

You want check for...

...integer values? -> char.IsDigit(char_var)

...floating point? -> char.IsDigit(char_var) || char_var == '.'

...plain letters? -> char.IsLetter(char_var)

...everything is white space -> char.IsWhiteSpace(char_var)

...symbols (+, -, etc..) -> char.IsSysmbol(char_var)

and many interesting method to test, parse or check your characters sequence!

Friday, 28 September 2007

System.Reflection.Emit wonders!

As I've said in one of first posts, one of the more exciting feature of CLR platform is the ability to create executable .NET code from another .NET program.
When you compile a source for .NET/CLR platform, the compiler translate the specific language syntax (C#, VB.NET, Managed C++, etc) in bytecode compatible with the CLR Virtual Machine.
The amazing thing is that you can create this bytecode using standard .NET API: System.Reflection and System.Reflection.Emit. For a simple but very useful demonstration follow this link to Joel Pobar's CLR weblog: the post explain how to create a classic "HelloWorld Program" using these APIs.

I hope that this example shows you how much this programmer tool can be powerful. The other important thing that I must to point out, is that dynamic code can be executed without being written to disk (therefore in memory).

This argument is too big for a single post; so I will back on Reflection.Emit, digging more deeper in these bits!
For the ones that can't wait, some useful links...

[1] CIL: the CLR assembler, formerly known as MSIL.
[2] Cecil: a powerful API (for inspect and generate CLR bytecode).
[3] PostSharp: a tool able to modify assembly injecting bytecode instructions (CIL)

Monday, 13 August 2007

Command Line Library Major Update ( RC0)

With Release Candidate 0 the project finally gets closer to its final shape. The help subsystem was integrated in the library and some internal refactoring was made.

More informations are available in the CodePlex release page; here you can also download the source code and the binaries.

Tuesday, 7 August 2007

GAC Extraction Utility for Mono released!

Many times when using Mono under Linux, I had the need to copy an assembly from the GAC to some local directory. Sometimes this can be useful for referencing purpose, when recompiling with NAnt. Other time you just want move an assembly with problems from production to test environment. In this way you can carrying out further verifications using exactly the same binaries.

You can download the first release (0.0 alfa) from

I wrote that program because I had need it, but is primarily an exercise because C++ is not my all-days programming language (however sometimes I had to write small pieces of a project in that language and above all I love use C and C++).

Future versions will be more platform (GNU Linux/Windows) and runtime (Mono/Microsoft .NET) indipendent.

Friday, 20 July 2007

Command Line Library Minor Update (

This release replaces the need of inheriting from ValueContainer class with the use of the new ValueListAttribute. This levels the programming model making the OO design more coherent.
As can use the OptionAttribute for define an option to parse:

class Options {

[Option ("o", "output")]
public string OutputFilename;

Now you can use the ValueListAttribute to store non-option values:

class Options {

[Option ("o", "output")]
public string OutputFilename;

[ValueList (typeof (List<string>))]
public IList<string> InputFilenames;

You must apply this new attribute to a field defined as IList<string> and define a compatible concrete instance type for the attribute constructor. This allows a good degree of customization without making more complex the programming model.
The release also features some internal rectoring and thread safety when modifying the options instance.

Give it a try.

Tuesday, 17 July 2007

Backup and Virtual Machine Images

In a development environment is now common the use of virtualization software for different reasons (testing the application in an another OS, made an IDE available to an OS that lacks that software, etc).
When I create a fresh guest installation, I like to backup the virtual disk image. If the virtualization app doesn't allow you to split the virtual disk in smaller files (like VMWare does), you have to do it by your self. If you don't split images greater than 2GB, you will exceed the ISO filesystem maximum allowed size.
In linux (or in Windows with Cygwin) you can use the split command to reduce these images:

split -db100000000 big_file.ext big_file.ext-

The number is a 1 followed by 8 zeroes and is expressed in bytes ('b' option), the 'd' switch tells split to use numeric suffix and the third parameter is the prefix. This command will produce n-files of 100MB named big_file.ext-00, big_file.ext-01, etc.
To join these file use the following command:

cat big_file.ext-* >big_file.ext

For completeness I must say that UDF filesystem supports files greater than 2GB, but in linux I had some problems with udftools (some blog post talks about a bug that limits again the file size - I've verified and it's true).

If you are searching a good virtualization product you can try VirtualBox. It's available in an opensource edition under GPL license.

Tuesday, 10 July 2007

Command Line Library Minor Update (

I've published a minor update ( that concerns maintainability. From this point I've planned some improvements for complete the project.
I'd like to add usage message creation and a class derived from OptionAttribute that works with arrays for handle non-option arguments (insted of ValueContainer).

What's more? I'd like to hear your opinion about the code...

Saturday, 30 June 2007

Add Command Line Parsing to your applications

Sometimes you have some job to get done (e.g.: loading custom format text files in to a db) and you must be fast. So you take your favorite editor and write a script in your favorite scripting language. Next time that a similar problem comes to you, you edit the script making it more parametric.
For accomplish this task you can take two ways (not mutually exclusives):
  1. use command line parameters
  2. use a configuration file
If the script importance is growing you can evaluate a porting to .NET/Mono platform and use my Command Line Parsing Library to easy parse command line arguments. (The project was recenlty moved from GotDotNet to CodePlex).
For managing conifiguration data check out my Common Utility Library (but be careful, the software is experimental and can change very quickly disrupting backward compatibility).

My personal taste is to use command line options and I've used the Command Line Parsing Library for this purpose for more than two years. The project will grow, but I think that for now is quite stable.

Tuesday, 26 June 2007

Mono compilation problem (GMCS)

I found a compilation problem working on a litte project that I want to publish as soon as possible.
The problem happens when inheriting from IEnumerator<T>. If you want to go deeper see the detailed description of bug 81948 on their bugzilla.

Thursday, 14 June 2007

Unit Tests Sources == Initial Documentation

If you publish a library with its source code, I think it's completely useless without some kind of documentation.
If these sources are subject to change frequently (because you're giving to the developers community a work under construction), you normally will not have time to prepare documentation and examples.

OK. In this case the only think you can't omit is including in your package unit tests sources.
Here I want to give prominence to coding unit test classes with the same accuracy you write the rest of the code.
Putting particular attention to name and to write high quality code inside test methods, it will produce your initial documentation "automatically".
Of course when you release an advanced beta or production quality code, you'll include a standard library reference (more on this argument in future).

Monday, 4 June 2007

Console.WriteLine("Hello World!");

I've finally decided to publish my personal web log. Even if my primary language is italian, I will post in english in order to allow more people to read it.
I know that my english is not perfect, for that please execuse me in advance. I hope however that it is sufficiently clear.

This blog will focus on .NET development. Published code will be 100% compatible with Mono the open source Linux/Unix incarnation of .NET (see their web site for detailed platforms support).