CODEDOM: Limitations of Codedom



      I have following questions,


    1. What are the limitations of System.Codedom in .NET 2.0?
    2. What changes are expected in System.Codedom in .NET 3.0?

      Please provide authentic links if possible.

    Thursday, April 19, 2007 3:57 AM


  • You can not generate (directly) something which is not in:

    But be aware that if you can generate the CodeDom, it does not mean you can generate code with it!

    See the following link for a list of things that are not supported by all CodeDomProvider:
    As you can see the list is quite large!

    Using some code transformation, you can transform some C# statements in CodeDom. Ex:
    int i = (a?b:c)+5;
    int temp__; if (a)   temp__ = b; else temp__ = c;
    int i = temp + 5;

    Using some equivalent construction, you can transform some C# statement in CodeDom. Ex: while loop into for loop, switch into if+label+goto.

    Using some CodeSnippet, you can write your own sugar (ex: [1]).

    Otherwise you can use some functions in a dll, or in the .Net Framwork.
    ex: a is b
    =>(Object.ReferenceEquals(var, null) == false && typeof(type).IsAssignableFrom(var.GetType()))

    Some other things are not possible, but are not vital, or you can go close to it.
    ex: static class A{ /*foobar*/}
    => sealed class A{private A(){} /*foobar*/}

    Also, some things seems possible, but do not generate correct code, for example the struct constraint[2].

    At the end, there is no limitation, because you can write your own CodeDomProvider. This can be simple if you build it on top of an existing CodeDomProvider.

    For the .Net3, the CodeDom should not change (no time to find a reference).

    Sorry, the following links are not official (written by me, there are some error that I will correct one day...):

    Thursday, April 19, 2007 9:35 AM