다음을 통해 공유


CodeGeneration Class

Definition

Contains utility methods for use in applications that generate PowerShell code.

public ref class CodeGeneration abstract sealed
public static class CodeGeneration
type CodeGeneration = class
Public Class CodeGeneration
Inheritance
CodeGeneration

Methods

EscapeBlockCommentContent(String)

Escapes content so that it is safe for inclusion in a block comment. For example: "<#" + EscapeBlockCommentContent(userContent) + "#>"

EscapeFormatStringContent(String)

Escapes content so that it is safe for inclusion in a string that will later be used as a format string. If this is to be embedded inside of a single-quoted string, be sure to also call EscapeSingleQuotedStringContent. For example: "'" + EscapeSingleQuotedStringContent(EscapeFormatStringContent(userContent)) + "'" -f $args.

EscapeSingleQuotedStringContent(String)

Escapes content so that it is safe for inclusion in a single-quoted string. For example: "'" + EscapeSingleQuotedStringContent(userContent) + "'"

EscapeVariableName(String)

Escapes content so that it is safe for inclusion in a string that will later be used in a variable name reference. This is only valid when used within PowerShell's curly brace naming syntax.

For example: '${' + EscapeVariableName('value') + '}'

Applies to