# Thursday, April 22, 2004

NDoc is truly an amazing library.

You can easily define your own documentation renderer (Documenter) class by implementing the NDoc.Core.IDocumenter interface (inheriting from BaseDocumenter will help). Once this is done, put the assembly ( named NDoc.Documenter.YourRenderer.dll) into the directory where NDocGUI.exe is and it will be loaded by Reflection where the GUI opens.

Since NLiterate is one way of looking at documentation, it deserved it's own documenter. The task was surprinsgly easy... maybe this could be my 2cents for NDoc :)

posted on Thursday, April 22, 2004 2:31:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]

I have published a new article on CodeProject about NLiterate ( http://www.codeproject.com/useritems/nliterate.asp )... don't forget to vote :)

 

posted on Thursday, April 22, 2004 9:56:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Wednesday, April 21, 2004

Literate programming ( http://www.literateprogramming.com  ) is a way of describing algorithms and programs invented by the the mythical D. Knuth (famous CWEB application). The nice thing about CWEB is that both code and documentation live in the same document. To compile the code, the tool reassembles the code snippets and compiles it. Therefore, you can verify that all the examples in your documentation are compilable. Sadly, the (excellent) C# documentation does not support literate programming... well now it does.

NLiterate is a small application that parses the XML documentation file, reassembles code section and compiles them. This gives you an automated way of testing all your documentation examples. I'll be posting the source soon.

posted on Wednesday, April 21, 2004 4:50:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Tuesday, April 20, 2004
I have released an article on using XML scripts to pilot SQLpp. Unfortunately, SQLpp is written in C++ and uses template meta-programming which makes compilation time explode. Therefore, the XML script should make it more "user friendly". The full article is at http://www.codeproject.com/useritems/xmlsqlpp.asp
posted on Tuesday, April 20, 2004 11:21:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]

I have been wondering if IDataReader was suited for remoting. The answer is obviously no since it derives from IMarshalByRef and therefore, all calls to the interface create a round-trip to the server.

Check out this article for more details.

posted on Tuesday, April 20, 2004 8:47:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
# Sunday, April 18, 2004
This little add-in makes Reflector spit out source code from an entire assembly. Scary and efficient.
posted on Sunday, April 18, 2004 12:00:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
This little add-in makes Reflector spit out source code from an entire assembly. Scary and efficient.
posted on Sunday, April 18, 2004 12:00:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
# Saturday, April 17, 2004

Consider the simple and tedious task of wrapping C++ classes into Managed C++ (MC++). The classic approach is to make a proxy around an instance of the C++ class allocated on the heap:

// the C++ class
class A {...};

// the MC++ wrapper
public __gc class MA
{
    A* a;
public:
    MA() { a = new A();}
    ~MA() { delete a;}
}

This works well for individual classes (although it is a tedious work) but it fails when it comes to map inherance. Let's add a second class to our example:

class A 
{
public:
    virtual void method();   
};

class B : public A
{
public:
    virtual void method();
}   

The proxies for A,B should map the inherance the original classes, therefore I would expect to have something like this:

public __gc class MB : MA
{
  ???
}
Now, the question is: where should I instanciate B, where should I store the pointer without making ugly casts all over-the-place. The answer is simple: Stop MC++ and wait C++/CLR announced in a near future. 
posted on Saturday, April 17, 2004 7:39:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Friday, April 16, 2004

Working on a database application, the urge for testing of database has appeared. Unfortunaltely, there are no real framework that can tackle this problem (real means with specialized assertion and fixtures). Unit test framework like NUnit are too simplistic to provide such functionality.

A little hope: I have run into this nice article which gives an introduction about database testing. The author gives a good methodology to set up a test framework for database:

    1. Separate production database from test database
    2. The test fixture must empty the tables of the test db befure launching the runs 
    3. do small unit tests using the business objects.

 There is one big gotcha about this: usually database are run in an "heavy" multithreaded environment and, in testing, we would like to detect locks and so on. The Unit test approach is too gentle :). I'll come back on this problem later (with somes solutions hopefully).

posted on Friday, April 16, 2004 1:22:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [2]

NDoc, the best and free documentation compiler for C# has lately released v1.3. This version adds a very interresting new feature: custom tags.Basically, you just need to provide the XSLT templates to NDoc and it use them to render you tags: simple, efficient and highly customizable.

In the NCollection project, we needed a way to easily document the complexity of methods (average and worst). A custom tag was the perfect solution for that: (hint: I'm using brackts intead of minus/greater)

/// [complexity worst="n" average="1" /]
public void Method()
{...}

Starting from the NDoc example, the XSLT stylesheet to render this tag is:

[xsl:template mode="remarks-section" match="complexity">
[H4 class=dtH4>Complexity[/H4]
    [UL]
        [LI]Average: O([xsl:value-of select="@average"][/xsl:value-of])
        [LI]Worst-case: O([xsl:value-of select="@worst"])[/LI]
    [/UL]
    [xsl:apply-templates select="*"/]
[/xsl:template]

Et voilà!

posted on Friday, April 16, 2004 12:34:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]