CodeGenerator.Optionsとは? わかりやすく解説

CodeGenerator.Options プロパティ


CodeGeneratorOptions クラス

コード ジェネレータで使用するオプションのセットを表します。

名前空間: System.CodeDom.Compiler
アセンブリ: System (system.dll 内)
構文構文

Public Class CodeGeneratorOptions
Dim instance As CodeGeneratorOptions
public class CodeGeneratorOptions
public ref class CodeGeneratorOptions
public class CodeGeneratorOptions
public class CodeGeneratorOptions
解説解説

CodeGeneratorOptions は、コード生成中に使用するオプションを指定するために、ICodeGenerator 実装のコード生成メソッドに渡されます。

IndentString プロパティは、各インデント幅に使用する文字列を指定します。BracingStyle プロパティは、コード ブロックの境界を示す中かっこの配置スタイルを指定します。ElseOnClosing プロパティは、if ブロックや try ブロックの終了行に、else、catch、finally の各ブロックを中かっこも含めて追加するかどうかを指定します。BlankLinesBetweenMembers プロパティは、各メンバの間に空行を挿入するかどうかを指定します。

ICodeGenerator 実装は、Item ディクショナリ インデクサを使用して、データを設定したり渡すことができるカスタム コード生成オプションを提供できます。コード ジェネレータは、このディクショナリを検索して、追加のコード生成オプションを見つけることができます。

メモメモ

このクラスは、すべてのメンバに適用されるリンク確認要求および継承確認要求をクラス レベルで格納します。直前の呼び出し元または派生クラスに完全信頼のアクセス許可がない場合、SecurityException がスローされます。セキュリティ要求の詳細については、「リンク確認要求」および「継承確認要求」を参照してください。

使用例使用例
' Creates a new CodeGeneratorOptions.
Dim genOptions As New CodeGeneratorOptions()

' Sets a value indicating that the code generator should insert blank
 lines between type members.
genOptions.BlankLinesBetweenMembers = True

' Sets the style of bracing format to use: either "Block"
 to start a
' bracing block on the same line as the declaration of its container,
 or 
' "C" to start the bracing for the block on the following
 line.
genOptions.BracingStyle = "C"

' Sets a value indicating that the code generator should not append
 an else, 
' catch or finally block, including brackets, at the closing line of
 a preceeding if or try block.
genOptions.ElseOnClosing = False

' Sets the string to indent each line with.
genOptions.IndentString = "    "

' Uses the CodeGeneratorOptions indexer property to set an
' example object to the type's string-keyed ListDictionary.
' Custom ICodeGenerator implementations can use objects 
' in this dictionary to customize process behavior.
genOptions("CustomGeneratorOptionStringExampleID")
 = "BuildFlags: /A /B /C /D /E"
// Creates a new CodeGeneratorOptions.
CodeGeneratorOptions genOptions = new CodeGeneratorOptions();

// Sets a value indicating that the code generator should insert blank
 lines between type members.
genOptions.BlankLinesBetweenMembers = true;

// Sets the style of bracing format to use: either "Block"
 to start a
// bracing block on the same line as the declaration of its container,
 or 
// "C" to start the bracing for the block on the following
 line.
genOptions.BracingStyle = "C";

// Sets a value indicating that the code generator should not append
 an else, 
// catch or finally block, including brackets, at the closing line of
 a preceeding if or try block.
genOptions.ElseOnClosing = false;

// Sets the string to indent each line with.
genOptions.IndentString = "    ";

// Uses the CodeGeneratorOptions indexer property to set an
// example object to the type's string-keyed ListDictionary.
// Custom ICodeGenerator implementations can use objects 
// in this dictionary to customize process behavior.
genOptions["CustomGeneratorOptionStringExampleID"] = "BuildFlags:
 /A /B /C /D /E";            
// Creates a new CodeGeneratorOptions.
CodeGeneratorOptions^ genOptions = gcnew CodeGeneratorOptions;

// Sets a value indicating that the code generator should insert blank
 lines between type members.
genOptions->BlankLinesBetweenMembers = true;

// Sets the style of bracing format to use: either S"Block"
 to start a
// bracing block on the same line as the declaration of its container,
 or
// S"C" to start the bracing for the block on the following
 line.
genOptions->BracingStyle = "C";

// Sets a value indicating that the code generator should not append
 an else,
// catch or finally block, including brackets, at the closing line of
 a preceeding if or try block.
genOptions->ElseOnClosing = false;

// Sets the String* to indent each line with.
genOptions->IndentString = "    ";

// Uses the CodeGeneratorOptions indexer property to set an
// example Object* to the type's String*-keyed ListDictionary.
// Custom ICodeGenerator* implementations can use objects
// in this dictionary to customize process behavior.
genOptions[ "CustomGeneratorOptionStringExampleID" ] = "BuildFlags:
 /A /B /C /D /E";
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.CodeDom.Compiler.CodeGeneratorOptions
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CodeGeneratorOptions メンバ
System.CodeDom.Compiler 名前空間

CodeGeneratorOptions コンストラクタ


CodeGeneratorOptions プロパティ


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

参照参照

関連項目

CodeGeneratorOptions クラス
System.CodeDom.Compiler 名前空間

CodeGeneratorOptions メソッド


CodeGeneratorOptions メンバ

コード ジェネレータで使用するオプションのセットを表します。

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CodeGeneratorOptions CodeGeneratorOptions クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CodeGeneratorOptions クラス
System.CodeDom.Compiler 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

CodeGenerator.Optionsのお隣キーワード
検索ランキング

   

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



CodeGenerator.Optionsのページの著作権

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

©2026 GRAS Group, Inc.RSS