CodeDom – An Progress Strategy For Code Generation at Operate Time


Categories :

CodeDom, which stands for Code Doc Item Design, is one progress strategy supplied by Microsoft.Web Framework to generate code at operate-time. At software degree, it presents programmers the functionality to write a solitary language-unbiased code that can emit source code in a certain language for afterwards needs.

Code Document Item Model lies inside of the Technique.CodeDom namespaces of the.Internet Framework. The CodeDom has the adhering to positive aspects:

From a one code that utilizes the CodeDom to depict the framework of source code that can make source code of any language supports the CodeDom specification.

The CodeDom allows source code and assemblies to be developed, compiled, and executed dynamically at runtime.

It supplies a language independent item model for representing the structure of resource code in memory.
It acts as a source code translator among distinct languages.

Typical usages of the CodeDOM consist of:

Producing template code for emitting code wizards, coding examples, XML Web solutions client proxies, and so forth.

Dynamically compiling code in languages supported.
T4 (Textual content Template Transformation Toolkit) is another powerful era device presented by Microsoft.web Framework. Unlike the CodeDom, T4 uses string concatenation to generate textual template to produce code. A lot of the output code will be place into template blocks, in order to make the code generator easy to generate and customise. Nonetheless, T4 is a language dependent and will need to have a individual code generator for each and every output language. On the other hand, the CodeDom permits developers use a solitary resource code to create the very same thing in diverse languages, which naturally give a massive advantage in creating.Net Framework resources.

Most programing constructs, such as declarations, statements, arrays, casts, iterations, mistake handling and other folks, is supported by the CodeDom. For programing constructs that are not presently supported in CodeDom, “snippet” classes like the CodeSnippetCompileUnit, CodeSnippetExpression, CodeSnippetStatement, and CodeSnippetTypeMember can be utilised as generic representation. For generating code in a certain language, a corresponding CodeDomProvider class will be essential.

At the moment there are Microsoft.CSharp.CSharpCodeProvider and Microsoft.VisualBasic.VBCodeProvider that can be employed to generate C Sharp code and VisuaBasic.net code. Other programming languages never have CodeDomProvider yet, and may not have straightforward methods to depict some CodeDom constructions (delegates, enums, templates, and framework) due to variation in language requirements. qr code generator Nevertheless, creating a CodeDomProvider is not a extremely sophisticated activity, if the input CodeDom composition is restricted. Programmers can constantly build a CodeDomProvider for a particular language by inheriting from CodeDomProvider, and toss exceptions if the building is way too difficult to signify.

Leave a Reply

Your email address will not be published. Required fields are marked *