This topic has not yet been rated - Rate this topic

ICodeGenerator Interface

Defines an interface for generating code.

Namespace:  System.CodeDom.Compiler
Assembly:  System (in System.dll)
public interface ICodeGenerator

The ICodeGenerator type exposes the following members.

  NameDescription
Public methodCreateEscapedIdentifierCreates an escaped identifier for the specified value.
Public methodCreateValidIdentifierCreates a valid identifier for the specified value.
Public methodGenerateCodeFromCompileUnitGenerates code for the specified Code Document Object Model (CodeDOM) compilation unit and outputs it to the specified text writer using the specified options.
Public methodGenerateCodeFromExpressionGenerates code for the specified Code Document Object Model (CodeDOM) expression and outputs it to the specified text writer.
Public methodGenerateCodeFromNamespaceGenerates code for the specified Code Document Object Model (CodeDOM) namespace and outputs it to the specified text writer using the specified options.
Public methodGenerateCodeFromStatementGenerates code for the specified Code Document Object Model (CodeDOM) statement and outputs it to the specified text writer using the specified options.
Public methodGenerateCodeFromTypeGenerates code for the specified Code Document Object Model (CodeDOM) type declaration and outputs it to the specified text writer using the specified options.
Public methodGetTypeOutputGets the type indicated by the specified CodeTypeReference.
Public methodIsValidIdentifierGets a value that indicates whether the specified value is a valid identifier for the current language.
Public methodSupportsGets a value indicating whether the generator provides support for the language features represented by the specified GeneratorSupport object.
Public methodValidateIdentifierThrows an exception if the specified value is not a valid identifier.
Top
NoteNote

In the .NET Framework versions 1.0 and 1.1, code providers consist of implementations of CodeDomProvider, ICodeGenerator, ICodeParser, and ICodeCompiler. In the .NET Framework 2.0, the CreateGenerator, CreateParser, and CreateCompiler methods are obsolete, and the methods of ICodeGenerator and ICodeCompiler are directly available in the CodeDomProvider class. You should override those methods in your code provider implementation and not call the base methods.

Developers of compilers can implement this interface to allow people to dynamically generate code in a particular language. This can be used for a variety of purposes, such as creating code-generating wizards, creating dynamic assemblies with content that can be debugged, and for templated documents with embedded code, such as ASP.NET.

An ICodeGenerator implementation is typically obtained through a call to the CreateGenerator method of CodeDomProvider.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.