As some of you may know, a huge part of the C# sources for db4o.net are generated from the Java version. This is possible because of the similarities of the two plaftorms, and of the two languages. So we have a converter, that takes care of translating the Java sources, to plain C# sources. So far, if the code we generated was readable by the C# compiler, it was a little harder to read for human eyes.
Let's take a small example. So, in the Java class ClassMetadata, we have this code:
public QCandidate readSubCandidate(MarshallerFamily mf, Buffer reader, QCandidates candidates, boolean withIndirection) {
int id = reader.readInt();
if (id == 0) {
return null;
}
return new QCandidate(candidates, null, id, true);
}
And here is the C# that was generated before:
public virtual Db4objects.Db4o.Internal.Query.Processor.QCandidate ReadSubCandidate
(Db4objects.Db4o.Internal.Marshall.MarshallerFamily mf, Db4objects.Db4o.Internal.Buffer
reader, Db4objects.Db4o.Internal.Query.Processor.QCandidates candidates, bool withIndirection
)
{
int id = reader.ReadInt();
if (id == 0)
{
return null;
}
return new Db4objects.Db4o.Internal.Query.Processor.QCandidate(candidates, null,
id, true);
}
If this is perfectly valid C#, it's not always easy to read, because every type is fully qualified.
But now, with the new improvements to our converter, we will organize the imports for every C# source file:
using Db4objects.Db4o.Internal;
using Db4objects.Db4o.Internal.Marshall;
using Db4objects.Db4o.Internal.Query.Processor;
// ...
public virtual QCandidate ReadSubCandidate(MarshallerFamily mf, Buffer
reader, QCandidates candidates, bool withIndirection)
{
int id = reader.ReadInt();
if (id == 0)
{
return null;
}
return new QCandidate(candidates, null, id, true);
}
This is still perfectly valid C#, but at least, it's much more readable. This is a little example, but imagine it applied to the thousands of thousands of line of code in db4o. I hope it will help those of you who are using the C# sources of db4o, and sometimes have to debug an issue that may have its root in db4o.
Now that it is done, how would you like we to improve the .net version of db4o?