Export (0) Print
Expand All

CodeGenerator Class

Provides an example implementation of the ICodeGenerator interface. This class is abstract.

System.Object
  System.CodeDom.Compiler.CodeGenerator
    System.CodeDom.Compiler.CodeCompiler

Namespace:  System.CodeDom.Compiler
Assembly:  System (in System.dll)

[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
public abstract class CodeGenerator : ICodeGenerator

The CodeGenerator type exposes the following members.

  NameDescription
Protected methodCodeGeneratorInitializes a new instance of the CodeGenerator class.
Top

  NameDescription
Protected propertyCurrentClassGets the code type declaration for the current class.
Protected propertyCurrentMemberGets the current member of the class.
Protected propertyCurrentMemberNameGets the current member name.
Protected propertyCurrentTypeNameGets the current class name.
Protected propertyIndentGets or sets the amount of spaces to indent each indentation level.
Protected propertyIsCurrentClassGets a value indicating whether the current object being generated is a class.
Protected propertyIsCurrentDelegateGets a value indicating whether the current object being generated is a delegate.
Protected propertyIsCurrentEnumGets a value indicating whether the current object being generated is an enumeration.
Protected propertyIsCurrentInterfaceGets a value indicating whether the current object being generated is an interface.
Protected propertyIsCurrentStructGets a value indicating whether the current object being generated is a value type or struct.
Protected propertyNullTokenGets the token that represents null.
Protected propertyOptionsGets the options to be used by the code generator.
Protected propertyOutputGets the text writer to use for output.
Top

  NameDescription
Protected methodContinueOnNewLineGenerates a line-continuation character and outputs the specified string on a new line.
Protected methodCreateEscapedIdentifierCreates an escaped identifier for the specified value.
Protected methodCreateValidIdentifierCreates a valid identifier for the specified value.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Protected methodGenerateArgumentReferenceExpressionGenerates code for the specified argument reference expression.
Protected methodGenerateArrayCreateExpressionGenerates code for the specified array creation expression.
Protected methodGenerateArrayIndexerExpressionGenerates code for the specified array indexer expression.
Protected methodGenerateAssignStatementGenerates code for the specified assignment statement.
Protected methodGenerateAttachEventStatementGenerates code for the specified attach event statement.
Protected methodGenerateAttributeDeclarationsEndGenerates code for the specified attribute block end.
Protected methodGenerateAttributeDeclarationsStartGenerates code for the specified attribute block start.
Protected methodGenerateBaseReferenceExpressionGenerates code for the specified base reference expression.
Protected methodGenerateBinaryOperatorExpressionGenerates code for the specified binary operator expression.
Protected methodGenerateCastExpressionGenerates code for the specified cast expression.
Public methodGenerateCodeFromMemberGenerates code for the specified class member using the specified text writer and code generator options.
Protected methodGenerateCommentGenerates code for the specified comment.
Protected methodGenerateCommentStatementGenerates code for the specified comment statement.
Protected methodGenerateCommentStatementsGenerates code for the specified comment statements.
Protected methodGenerateCompileUnitGenerates code for the specified compile unit.
Protected methodGenerateCompileUnitEndGenerates code for the end of a compile unit.
Protected methodGenerateCompileUnitStartGenerates code for the start of a compile unit.
Protected methodGenerateConditionStatementGenerates code for the specified conditional statement.
Protected methodGenerateConstructorGenerates code for the specified constructor.
Protected methodGenerateDecimalValueGenerates code for the specified decimal value.
Protected methodGenerateDefaultValueExpressionGenerates code for the specified reference to a default value.
Protected methodGenerateDelegateCreateExpressionGenerates code for the specified delegate creation expression.
Protected methodGenerateDelegateInvokeExpressionGenerates code for the specified delegate invoke expression.
Protected methodGenerateDirectionExpressionGenerates code for the specified direction expression.
Protected methodGenerateDirectivesGenerates code for the specified code directives.
Protected methodGenerateDoubleValueGenerates code for a double-precision floating point number.
Protected methodGenerateEntryPointMethodGenerates code for the specified entry point method.
Protected methodGenerateEventGenerates code for the specified event.
Protected methodGenerateEventReferenceExpressionGenerates code for the specified event reference expression.
Protected methodGenerateExpressionGenerates code for the specified code expression.
Protected methodGenerateExpressionStatementGenerates code for the specified expression statement.
Protected methodGenerateFieldGenerates code for the specified member field.
Protected methodGenerateFieldReferenceExpressionGenerates code for the specified field reference expression.
Protected methodGenerateGotoStatementGenerates code for the specified goto statement.
Protected methodGenerateIndexerExpressionGenerates code for the specified indexer expression.
Protected methodGenerateIterationStatementGenerates code for the specified iteration statement.
Protected methodGenerateLabeledStatementGenerates code for the specified labeled statement.
Protected methodGenerateLinePragmaEndGenerates code for the specified line pragma end.
Protected methodGenerateLinePragmaStartGenerates code for the specified line pragma start.
Protected methodGenerateMethodGenerates code for the specified method.
Protected methodGenerateMethodInvokeExpressionGenerates code for the specified method invoke expression.
Protected methodGenerateMethodReferenceExpressionGenerates code for the specified method reference expression.
Protected methodGenerateMethodReturnStatementGenerates code for the specified method return statement.
Protected methodGenerateNamespaceGenerates code for the specified namespace.
Protected methodGenerateNamespaceEndGenerates code for the end of a namespace.
Protected methodGenerateNamespaceImportGenerates code for the specified namespace import.
Protected methodGenerateNamespaceImportsGenerates code for the specified namespace import.
Protected methodGenerateNamespacesGenerates code for the namespaces in the specified compile unit.
Protected methodGenerateNamespaceStartGenerates code for the start of a namespace.
Protected methodGenerateObjectCreateExpressionGenerates code for the specified object creation expression.
Protected methodGenerateParameterDeclarationExpressionGenerates code for the specified parameter declaration expression.
Protected methodGeneratePrimitiveExpressionGenerates code for the specified primitive expression.
Protected methodGeneratePropertyGenerates code for the specified property.
Protected methodGeneratePropertyReferenceExpressionGenerates code for the specified property reference expression.
Protected methodGeneratePropertySetValueReferenceExpressionGenerates code for the specified property set value reference expression.
Protected methodGenerateRemoveEventStatementGenerates code for the specified remove event statement.
Protected methodGenerateSingleFloatValueGenerates code for a single-precision floating point number.
Protected methodGenerateSnippetCompileUnitOutputs the code of the specified literal code fragment compile unit.
Protected methodGenerateSnippetExpressionOutputs the code of the specified literal code fragment expression.
Protected methodGenerateSnippetMemberOutputs the code of the specified literal code fragment class member.
Protected methodGenerateSnippetStatementOutputs the code of the specified literal code fragment statement.
Protected methodGenerateStatementGenerates code for the specified statement.
Protected methodGenerateStatementsGenerates code for the specified statement collection.
Protected methodGenerateThisReferenceExpressionGenerates code for the specified this reference expression.
Protected methodGenerateThrowExceptionStatementGenerates code for the specified throw exception statement.
Protected methodGenerateTryCatchFinallyStatementGenerates code for the specified try...catch...finally statement.
Protected methodGenerateTypeConstructorGenerates code for the specified class constructor.
Protected methodGenerateTypeEndGenerates code for the specified end of the class.
Protected methodGenerateTypeOfExpressionGenerates code for the specified type of expression.
Protected methodGenerateTypeReferenceExpressionGenerates code for the specified type reference expression.
Protected methodGenerateTypesGenerates code for the specified namespace and the classes it contains.
Protected methodGenerateTypeStartGenerates code for the specified start of the class.
Protected methodGenerateVariableDeclarationStatementGenerates code for the specified variable declaration statement.
Protected methodGenerateVariableReferenceExpressionGenerates code for the specified variable reference expression.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodGetTypeOutputGets the name of the specified data type.
Protected methodIsValidIdentifierGets a value indicating whether the specified value is a valid identifier.
Public methodStatic memberIsValidLanguageIndependentIdentifierGets a value indicating whether the specified string is a valid identifier.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOutputAttributeArgumentOutputs an argument in an attribute block.
Protected methodOutputAttributeDeclarationsGenerates code for the specified attribute declaration collection.
Protected methodOutputDirectionGenerates code for the specified FieldDirection.
Protected methodOutputExpressionList(CodeExpressionCollection)Generates code for the specified expression list.
Protected methodOutputExpressionList(CodeExpressionCollection, Boolean)Generates code for the specified expression list.
Protected methodOutputFieldScopeModifierOutputs a field scope modifier that corresponds to the specified attributes.
Protected methodOutputIdentifierOutputs the specified identifier.
Protected methodOutputMemberAccessModifierGenerates code for the specified member access modifier.
Protected methodOutputMemberScopeModifierGenerates code for the specified member scope modifier.
Protected methodOutputOperatorGenerates code for the specified operator.
Protected methodOutputParametersGenerates code for the specified parameters.
Protected methodOutputTypeGenerates code for the specified type.
Protected methodOutputTypeAttributesGenerates code for the specified type attributes.
Protected methodOutputTypeNamePairGenerates code for the specified object type and name pair.
Protected methodQuoteSnippetStringConverts the specified string by formatting it with escape codes.
Protected methodSupportsGets a value indicating whether the specified code generation support is provided.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodValidateIdentifierThrows an exception if the specified string is not a valid identifier.
Public methodStatic memberValidateIdentifiersAttempts to validate each identifier field contained in the specified CodeObject or System.CodeDom tree.
Top

  NameDescription
Explicit interface implemetationPrivate methodICodeGenerator.CreateEscapedIdentifierInfrastructure. Creates an escaped identifier for the specified value.
Explicit interface implemetationPrivate methodICodeGenerator.CreateValidIdentifierInfrastructure. Creates a valid identifier for the specified value.
Explicit interface implemetationPrivate methodICodeGenerator.GenerateCodeFromCompileUnitInfrastructure. Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and outputs it to the specified text writer using the specified options.
Explicit interface implemetationPrivate methodICodeGenerator.GenerateCodeFromExpressionInfrastructure. Generates code for the specified Code Document Object Model (CodeDOM) expression and outputs it to the specified text writer.
Explicit interface implemetationPrivate methodICodeGenerator.GenerateCodeFromNamespaceInfrastructure. Generates code for the specified Code Document Object Model (CodeDOM) namespace and outputs it to the specified text writer using the specified options.
Explicit interface implemetationPrivate methodICodeGenerator.GenerateCodeFromStatementInfrastructure. Generates code for the specified Code Document Object Model (CodeDOM) statement and outputs it to the specified text writer using the specified options.
Explicit interface implemetationPrivate methodICodeGenerator.GenerateCodeFromTypeInfrastructure. Generates code for the specified Code Document Object Model (CodeDOM) type declaration and outputs it to the specified text writer using the specified options.
Explicit interface implemetationPrivate methodICodeGenerator.GetTypeOutputInfrastructure. Gets the type indicated by the specified CodeTypeReference.
Explicit interface implemetationPrivate methodICodeGenerator.IsValidIdentifierInfrastructure. Gets a value that indicates whether the specified value is a valid identifier for the current language.
Explicit interface implemetationPrivate methodICodeGenerator.SupportsInfrastructure. Gets a value indicating whether the generator provides support for the language features represented by the specified GeneratorSupport object.
Explicit interface implemetationPrivate methodICodeGenerator.ValidateIdentifierInfrastructure. Throws an exception if the specified value is not a valid identifier.
Top

This is a useful base class for code generators to derive from. Code generators are capable of rendering source code in a specific language according to the structure of a Code Document Object Model (CodeDOM) graph. This class provides many functions and methods to generate specific types of code from a CodeDOM graph.

NoteNote

This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft