Assembly: System (in system.dll)
CodeGeneratorOptions is passed to the code generation methods of an ICodeGenerator implementation to specify options used during code generation.
The IndentString property specifies the string to use for each spacing indentation. The BracingStyle property specifies the placement style for braces indicating the boundaries of code blocks. The ElseOnClosing property specifies whether to append an else, catch, or finally block, including brackets, at the closing line of each if or try block. The BlankLinesBetweenMembers property specifies whether to insert blank lines between members.
An ICodeGenerator implementation can provide custom code generation options which you can set or pass data to using the Item dictionary indexer, which a code generator can search through to locate additional code generation options.
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.
// 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";
- 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.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.