Amplication AST Libraries Documentation
    Preparing search index...

    Represents a C# method in the AST. This class handles the generation of C# method declarations including parameters, return type, body, and annotations.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    name: string

    The name of the method

    isAsync: boolean

    Whether the method is asynchronous

    access: Access

    The access level of the method

    return: undefined | Type

    The return type of the method

    body: undefined | CodeBlock

    The body of the method

    summary: undefined | string

    XML documentation summary for the method

    The type of the method (instance or static)

    reference: undefined | ClassReference

    The class reference for this method

    classType: MethodClassType = MethodClassType.CLASS

    The type of class containing this method

    annotations?: Annotation[]

    The annotations applied to this method

    splitAnnotations?: boolean

    Whether to split annotations onto separate lines

    Methods

    • Adds a parameter to the method.

      Parameters

      Returns void

    • Writes the method declaration and its body to the writer.

      Parameters

      • writer: Writer

        The writer to write to

      Returns void

    • Gets all parameters of the method.

      Returns Parameter[]

      The method parameters

    • Creates a method invocation for this method using example values.

      Parameters

      • example: Map<string, unknown>

        Map of parameter names to example values

      • Optionalon: CodeBlock

        Optional code block to invoke the method on

      Returns MethodInvocation

      The method invocation

    • Returns the string representation of the AST node. This method creates a new Writer instance and writes the node's content to it.

      Returns string

      The string representation of the AST node