TechNet
Export (0) Print
Expand All

CodeDomProvider Class

 

Provides a base class for CodeDomProvider implementations. This class is abstract.

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

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.CodeDom.Compiler.CodeDomProvider
        Microsoft.CSharp.CSharpCodeProvider
        Microsoft.JScript.JScriptCodeProvider
        Microsoft.VisualBasic.VBCodeProvider

[<AbstractClass>]
[<ComVisibleAttribute(true)>]
[<PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")>]
[<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")>]
type CodeDomProvider = 
    class
        inherit Component
    end

NameDescription
System_CAPS_protmethodCodeDomProvider()

Initializes a new instance of the CodeDomProvider class.

NameDescription
System_CAPS_protpropertyCanRaiseEvents

Gets a value indicating whether the component can raise an event.(Inherited from Component.)

System_CAPS_pubpropertyContainer

Gets the IContainer that contains the Component.(Inherited from Component.)

System_CAPS_protpropertyDesignMode

Gets a value that indicates whether the Component is currently in design mode.(Inherited from Component.)

System_CAPS_protpropertyEvents

Gets the list of event handlers that are attached to this Component.(Inherited from Component.)

System_CAPS_pubpropertyFileExtension

Gets the default file name extension to use for source code files in the current language.

System_CAPS_pubpropertyLanguageOptions

Gets a language features identifier.

System_CAPS_pubpropertySite

Gets or sets the ISite of the Component.(Inherited from Component.)

NameDescription
System_CAPS_pubmethodCompileAssemblyFromDom(CompilerParameters, CodeCompileUnit[])

Compiles an assembly based on the System.CodeDom trees contained in the specified array of CodeCompileUnit objects, using the specified compiler settings.

System_CAPS_pubmethodCompileAssemblyFromFile(CompilerParameters, String[])

Compiles an assembly from the source code contained in the specified files, using the specified compiler settings.

System_CAPS_pubmethodCompileAssemblyFromSource(CompilerParameters, String[])

Compiles an assembly from the specified array of strings containing source code, using the specified compiler settings.

System_CAPS_pubmethodCreateCompiler()

Obsolete.When overridden in a derived class, creates a new code compiler.

System_CAPS_pubmethodCreateEscapedIdentifier(String)

Creates an escaped identifier for the specified value.

System_CAPS_pubmethodCreateGenerator()

Obsolete.When overridden in a derived class, creates a new code generator.

System_CAPS_pubmethodCreateGenerator(String)

When overridden in a derived class, creates a new code generator using the specified file name for output.

System_CAPS_pubmethodCreateGenerator(TextWriter)

When overridden in a derived class, creates a new code generator using the specified TextWriter for output.

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodCreateParser()

Obsolete.When overridden in a derived class, creates a new code parser.

System_CAPS_pubmethodSystem_CAPS_staticCreateProvider(String)

Gets a CodeDomProvider instance for the specified language.

System_CAPS_pubmethodSystem_CAPS_staticCreateProvider(String, IDictionary<String, String>)

Gets a CodeDomProvider instance for the specified language and provider options.

System_CAPS_pubmethodCreateValidIdentifier(String)

Creates a valid identifier for the specified value.

System_CAPS_pubmethodDispose()

Releases all resources used by the Component.(Inherited from Component.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.(Inherited from Component.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.(Inherited from Component.)

System_CAPS_pubmethodGenerateCodeFromCompileUnit(CodeCompileUnit, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and sends it to the specified text writer, using the specified options.

System_CAPS_pubmethodGenerateCodeFromExpression(CodeExpression, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) expression and sends it to the specified text writer, using the specified options.

System_CAPS_pubmethodGenerateCodeFromMember(CodeTypeMember, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) member declaration and sends it to the specified text writer, using the specified options.

System_CAPS_pubmethodGenerateCodeFromNamespace(CodeNamespace, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) namespace and sends it to the specified text writer, using the specified options.

System_CAPS_pubmethodGenerateCodeFromStatement(CodeStatement, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) statement and sends it to the specified text writer, using the specified options.

System_CAPS_pubmethodGenerateCodeFromType(CodeTypeDeclaration, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) type declaration and sends it to the specified text writer, using the specified options.

System_CAPS_pubmethodSystem_CAPS_staticGetAllCompilerInfo()

Returns the language provider and compiler configuration settings for this computer.

System_CAPS_pubmethodSystem_CAPS_staticGetCompilerInfo(String)

Returns the language provider and compiler configuration settings for the specified language.

System_CAPS_pubmethodGetConverter(Type)

Gets a TypeConverter for the specified data type.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetLanguageFromExtension(String)

Returns a language name associated with the specified file name extension, as configured in the CodeDomProvider compiler configuration section.

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodGetService(Type)

Returns an object that represents a service provided by the Component or by its Container.(Inherited from Component.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetTypeOutput(CodeTypeReference)

Gets the type indicated by the specified CodeTypeReference.

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodSystem_CAPS_staticIsDefinedExtension(String)

Tests whether a file name extension has an associated CodeDomProvider implementation configured on the computer.

System_CAPS_pubmethodSystem_CAPS_staticIsDefinedLanguage(String)

Tests whether a language has a CodeDomProvider implementation configured on the computer.

System_CAPS_pubmethodIsValidIdentifier(String)

Returns a value that indicates whether the specified value is a valid identifier for the current language.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodParse(TextReader)

Compiles the code read from the specified text stream into a CodeCompileUnit.

System_CAPS_pubmethodSupports(GeneratorSupport)

Returns a value indicating whether the specified code generation support is provided.

System_CAPS_pubmethodToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.(Inherited from Component.)

NameDescription
System_CAPS_pubeventDisposed

Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)

A CodeDomProvider can be used to create and retrieve instances of code generators and code compilers. Code generators can be used to generate code in a particular language, and code compilers can be used to compile code into assemblies.

System_CAPS_noteNote

In the .NET Framework 2.0, the methods made available in the code generator and code compiler are available directly from the code provider. You do not need to call CreateGenerator or CreateCompiler to access the methods, and those methods are marked as obsolete. This applies to preexisting as well as new code provider implementations.

A CodeDomProvider implementation typically provides code generation and/or code compilation interfaces for generating code and managing compilation for a single programming language. Several languages are supported by CodeDomProvider implementations that ship with the Windows Software Development Kit (SDK). These languages include C#, Visual Basic, C++, and JScript. Developers or compiler vendors can implement the ICodeGenerator and ICodeCompiler interfaces and provide a CodeDomProvider that extends CodeDOM support to other programming languages.

The <system.codedom> Element in the machine configuration file (Machine.config) provides a mechanism for developers and compiler vendors to add configuration settings for additional CodeDomProvider implementations.

The CodeDomProvider class provides static methods to discover and enumerate the CodeDomProvider implementations on a computer. The GetAllCompilerInfo method returns the settings for all CodeDomProvider implementations on a computer. The GetCompilerInfo method returns the settings for a specific CodeDomProvider implementation, based on the programming language name. The CreateProvider method returns an instance of a CodeDomProvider implementation for a specific language.

For more details on language provider settings in the configuration file, see Compiler and Language Provider Settings Schema.

System_CAPS_noteNote

This class makes a link demand and an inheritance demand at the class level. A SecurityException is thrown if 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.

Notes to Inheritors:

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.

The following example program can generate and compile source code based on a CodeDOM model of a program that prints "Hello World" using the Console class. A Windows Forms user interface is provided. The user can select the target programming language from several selections: C#, Visual Basic, and JScript.

No code example is currently available or this language may not be supported.

SecurityAction.LinkDemand

for full trust for the immediate caller. This class cannot be used by partially trusted code.

SecurityAction.InheritanceDemand

for full trust for inheritors. This class cannot be inherited by partially trusted code.

.NET Framework
Available since 1.1

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

Return to top
Show:
© 2016 Microsoft