CompilerTypeとは? わかりやすく解説

Compiler.Type プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

動的コンパイル ファイル言語プロバイダコンパイラ種類を示す名前を取得します

名前空間: System.Web.Configuration
アセンブリ: System.Web (system.web.dll 内)
構文構文

解説解説

言語プロバイダ種類を示す名前 (プロバイダ実装を表すアセンブリの名前を含む) を指定します

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

CompilerType クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

仮想パスからソース コード生成コンパイルを行うために ASP.NET ビルド環境使用するコンパイラ設定表します。このクラス継承できません。

名前空間: System.Web.Compilation
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 CompilerType
public sealed class CompilerType
public ref class CompilerType sealed
public final class CompilerType
public final class CompilerType
解説解説
使用例使用例

簡単なビルド プロバイダを、抽象基本クラス BuildProvider から継承して実装するコード例次に示しますビルド プロバイダは、基本クラスメンバである CodeCompilerType、GetGeneratedType、および GenerateCode をオーバーライドます。

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.IO
Imports System.Text
Imports System.Web
Imports System.Web.Compilation
Imports System.CodeDom.Compiler
Imports System.CodeDom
Imports System.Security
Imports System.Security.Permissions

<PermissionSet(SecurityAction.Demand, Unrestricted := true)>
 _
Public Class SampleBuildProvider
    Inherits BuildProvider

    Protected _compilerType As CompilerType
 = Nothing

    Public Sub New()
        _compilerType = GetDefaultCompilerType()
    End Sub

    ' Return the internal CompilerType member 
    ' defined in this implementation.
    Public Overrides ReadOnly
 Property CodeCompilerType() As CompilerType
        Get
            CodeCompilerType = _compilerType
        End Get
    End Property

    ' Define a method that returns details for the 
    ' code compiler for this build provider.
    Public Function GetCompilerTypeDetails()
 As String
        Dim details As StringBuilder = New
 StringBuilder("")

        If Not _compilerType Is
 Nothing Then
            ' Format a string that contains the code compiler
            ' implementation, and various compiler details.

            details.AppendFormat("CodeDomProvider type: {0}; ",
 _
                _compilerType.CodeDomProviderType.ToString())
            details.AppendFormat("Compiler debug build = {0};
 ", _
                _compilerType.CompilerParameters.IncludeDebugInformation.ToString())
            details.AppendFormat("Compiler warning level = {0};
 ", _
                _compilerType.CompilerParameters.WarningLevel.ToString())

            If Not _compilerType.CompilerParameters.CompilerOptions
 Is Nothing Then
                details.AppendFormat("Compiler options: {0}; ",
 _
                    _compilerType.CompilerParameters.CompilerOptions.ToString())
            End If
        End If
        Return details.ToString()
    End Function

    ' Define the build provider implementation of the GenerateCode method.
    Public Overrides Sub
 GenerateCode(ByVal assemBuilder As AssemblyBuilder)
        ' Generate a code compile unit, and add it to
        ' the assembly builder.

        Dim tw As TextWriter = assemBuilder.CreateCodeFile(Me)
        If Not tw Is Nothing
 Then
            Try
                ' Generate the code compile unit from the virtual path.
                Dim compileUnit As CodeCompileUnit
 = _
                        SampleClassGenerator.BuildCompileUnitFromPath(VirtualPath)

                ' Generate the source for the code compile unit, 
                ' and write it to a file specified by the assembly builder.
                Dim provider As CodeDomProvider
 = assemBuilder.CodeDomProvider
                provider.CreateGenerator().GenerateCodeFromCompileUnit(compileUnit,
 tw, Nothing)
            Finally
                tw.Close()
            End Try

        End If
    End Sub

    Public Overrides Function
 GetGeneratedType(ByVal results As CompilerResults)
 As System.Type
        Dim typeName As String
 = SampleClassGenerator.TypeName

        Return results.CompiledAssembly.GetType(typeName)
    End Function

End Class
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Compilation;
using System.CodeDom.Compiler;
using System.CodeDom;
using System.Security;
using System.Security.Permissions;

// Define a simple build provider implementation.
[PermissionSet(SecurityAction.Demand, Unrestricted = true)]
public class SampleBuildProvider : BuildProvider
{
    // Define an internal member for the compiler type.
    protected CompilerType _compilerType = null;

    public SampleBuildProvider()
    {
        // Set the compiler to use Visual Basic.
        _compilerType = GetDefaultCompilerTypeForLanguage("C#");
    }

    // Return the internal CompilerType member 
    // defined in this implementation.
    public override CompilerType CodeCompilerType
    {
        get { return _compilerType; }
    }

    // Define a method that returns details for the 
    // code compiler for this build provider.
    public string GetCompilerTypeDetails()
    {
        StringBuilder details = new StringBuilder("");

        if (_compilerType != null)
        {
            // Format a string that contains the code compiler
            // implementation, and various compiler details.

            details.AppendFormat("CodeDomProvider type: {0}; \n",
                _compilerType.CodeDomProviderType.ToString());
            details.AppendFormat("Compiler debug build = {0}; \n",
                _compilerType.CompilerParameters.IncludeDebugInformation.ToString());
            details.AppendFormat("Compiler warning level = {0}; \n",
                _compilerType.CompilerParameters.WarningLevel.ToString());

            if (_compilerType.CompilerParameters.CompilerOptions
 != null)
            {
                details.AppendFormat("Compiler options: {0}; \n",
                    _compilerType.CompilerParameters.CompilerOptions.ToString());
            }
        }
        return details.ToString();
    }


    // Define the build provider implementation of the GenerateCode
 method.
    public override void GenerateCode(AssemblyBuilder
 assemBuilder)
    {
        // Generate a code compile unit, and add it to
        // the assembly builder.

        TextWriter tw = assemBuilder.CreateCodeFile(this);
        if (tw != null)
        {
            try
            {
                // Generate the code compile unit from the virtual path.
                CodeCompileUnit compileUnit = SampleClassGenerator.BuildCompileUnitFromPath(VirtualPath);

                // Generate the source for the code compile unit, 
                // and write it to a file specified by the assembly
 builder.
                CodeDomProvider provider = assemBuilder.CodeDomProvider;
                provider.CreateGenerator().GenerateCodeFromCompileUnit(compileUnit,
 tw, null);
            }
            finally
            {
                tw.Close();
            }
        }
    }

    public override System.Type GetGeneratedType(CompilerResults
 results)
    {
        string typeName = SampleClassGenerator.TypeName;

        return results.CompiledAssembly.GetType(typeName);
    }
}
継承階層継承階層
System.Object
  System.Web.Compilation.CompilerType
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CompilerType メンバ
System.Web.Compilation 名前空間
CompilerParameters
CodeDomProvider
BuildProvider クラス

CompilerType プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ CodeDomProviderType 構成済みの CodeDomProvider 実装対すType取得します
パブリック プロパティ CompilerParameters ソース コードアセンブリコンパイルするために使用する設定オプション取得します
参照参照

関連項目

CompilerType クラス
System.Web.Compilation 名前空間
CompilerParameters
CodeDomProvider
BuildProvider クラス

CompilerType メソッド


CompilerType メンバ

仮想パスからソース コード生成コンパイルを行うために ASP.NET ビルド環境使用するコンパイラ設定表します。このクラス継承できません。

CompilerType データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ CodeDomProviderType 構成済みの CodeDomProvider 実装対すType取得します
パブリック プロパティ CompilerParameters ソース コードアセンブリコンパイルするために使用する設定オプション取得します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CompilerType クラス
System.Web.Compilation 名前空間
CompilerParameters
CodeDomProvider
BuildProvider クラス


このページでは「.NET Framework クラス ライブラリ リファレンス」からCompilerTypeを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCompilerTypeを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCompilerType を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CompilerType」の関連用語

CompilerTypeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CompilerTypeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS