Today I’m converting a project written in VB to C#, since it is composed by simple classes that manages reporting in RTF, I supposed that this will be a simple process. This project uses a RTF library I wrote in Visual Basic in 2002, that was simply compiled for.NET 2.0 some times ago.
The problem is that the library is really not CLS compliant and when I converted this project, (that contains 54 classes) I got ~ 2000 compilation errors. This because the library uses a lot of not CLS features, and converting library to C# caused me a lot of troubles.
First, I used indexed properties with parameter, something like this.
This is a property called RowProperty that require an Integer parameter, clearly when the project was converted in C# the result is this one :)
That is not valid code, it raises the error
This permits to me to change every occurrence of.RowProperty[index] with.get_RowProperty(index). There are also a lot of failing call to method with default parameter, not supported in C# 3.5…
This remind me that every Assembly MUst always be marked with the CLSCompliantAttribute and make sure that it is CLS compliant to avoid problem using it with different languages :(