================================================================================
Table with preprocessor conditional procedures
================================================================================

table 50100 "Test Table"
{
    fields
    {
        field(1; "Code"; Code[20])
        {
            Caption = 'Code';
        }
    }

#if not CLEAN25
    [Obsolete('This procedure is deprecated.', '25.0')]
    procedure OldProcedure()
    begin
        Message('Old procedure');
    end;
#endif

    procedure NewProcedure()
    begin
        Message('New procedure');
    end;
}

--------------------------------------------------------------------------------

(source_file
  (table_declaration
    (table_keyword)
    object_id: (integer)
    object_name: (quoted_identifier)
    (fields_section
      (fields_keyword)
      (field_declaration
        id: (integer)
        name: (quoted_identifier)
        type: (type_specification
          (code_type
            length: (integer)))
        (property
          name: (property_name)
          value: (string_literal))))
    (preproc_conditional
      (preproc_if
        condition: (preproc_not_expression
          (identifier)))
      (attribute_item
        attribute: (attribute_content
          name: (identifier)
          arguments: (attribute_arguments
            (attribute_argument_list
              (string_literal)
              (string_literal)))))
      (procedure
        (procedure_keyword)
        name: (identifier)
        (code_block
          (call_expression
            function: (identifier)
            arguments: (argument_list
              (string_literal)))))
      (preproc_endif))
    (procedure
      (procedure_keyword)
      name: (identifier)
      (code_block
        (call_expression
          function: (identifier)
          arguments: (argument_list
            (string_literal)))))))

================================================================================
Table with multiple preprocessor conditional procedures
================================================================================

table 50101 "VAT Amount Line"
{
#if not CLEAN26
    [Obsolete('Replaced by procedures using Source Record.', '26.0')]
    procedure InsertNewLine(VATIdentifier: Code[20]; TaxRate: Decimal)
    begin
        Rec.Init();
        Rec."VAT Identifier" := VATIdentifier;
        Rec."VAT %" := TaxRate;
        Rec.Insert();
    end;
#endif

#if not CLEAN25
    [Obsolete('Replaced by procedures using Source Record.', '25.0')]
    procedure SumLine(LineAmount: Decimal; InvDiscAmount: Decimal)
    begin
        "Line Amount" += LineAmount;
        "Invoice Discount Amount" += InvDiscAmount;
        Modify();
    end;
#endif

    procedure UpdateLines()
    begin
        Message('Updating lines');
    end;
}

--------------------------------------------------------------------------------

(source_file
  (table_declaration
    (table_keyword)
    object_id: (integer)
    object_name: (quoted_identifier)
    (preproc_conditional
      (preproc_if
        condition: (preproc_not_expression
          (identifier)))
      (attribute_item
        attribute: (attribute_content
          name: (identifier)
          arguments: (attribute_arguments
            (attribute_argument_list
              (string_literal)
              (string_literal)))))
      (procedure
        (procedure_keyword)
        name: (identifier)
        (parameter_list
          (parameter
            name: (identifier)
            type: (type_specification
              (code_type
                length: (integer))))
          (parameter
            name: (identifier)
            type: (type_specification
              (basic_type))))
        (code_block
          (call_expression
            function: (member_expression
              object: (identifier)
              member: (identifier))
            arguments: (argument_list))
          (assignment_statement
            left: (member_expression
              object: (identifier)
              member: (quoted_identifier))
            right: (identifier))
          (assignment_statement
            left: (member_expression
              object: (identifier)
              member: (quoted_identifier))
            right: (identifier))
          (call_expression
            function: (member_expression
              object: (identifier)
              member: (identifier))
            arguments: (argument_list))))
      (preproc_endif))
    (preproc_conditional
      (preproc_if
        condition: (preproc_not_expression
          (identifier)))
      (attribute_item
        attribute: (attribute_content
          name: (identifier)
          arguments: (attribute_arguments
            (attribute_argument_list
              (string_literal)
              (string_literal)))))
      (procedure
        (procedure_keyword)
        name: (identifier)
        (parameter_list
          (parameter
            name: (identifier)
            type: (type_specification
              (basic_type)))
          (parameter
            name: (identifier)
            type: (type_specification
              (basic_type))))
        (code_block
          (assignment_statement
            left: (quoted_identifier)
            right: (identifier))
          (assignment_statement
            left: (quoted_identifier)
            right: (identifier))
          (call_expression
            function: (identifier)
            arguments: (argument_list))))
      (preproc_endif))
    (procedure
      (procedure_keyword)
      name: (identifier)
      (code_block
        (call_expression
          function: (identifier)
          arguments: (argument_list
            (string_literal)))))))

================================================================================
Table with preprocessor else branch procedures
================================================================================

table 50102 "Test Table"
{
#if CLEAN25
    procedure ModernProcedure()
    begin
        Message('Modern implementation');
    end;
#else
    [Obsolete('Use ModernProcedure instead', '25.0')]
    procedure LegacyProcedure()
    begin
        Message('Legacy implementation');
    end;
#endif
}

--------------------------------------------------------------------------------

(source_file
  (table_declaration
    (table_keyword)
    object_id: (integer)
    object_name: (quoted_identifier)
    (preproc_conditional
      (preproc_if
        condition: (identifier))
      (procedure
        (procedure_keyword)
        name: (identifier)
        (code_block
          (call_expression
            function: (identifier)
            arguments: (argument_list
              (string_literal)))))
      (preproc_else)
      (attribute_item
        attribute: (attribute_content
          name: (identifier)
          arguments: (attribute_arguments
            (attribute_argument_list
              (string_literal)
              (string_literal)))))
      (procedure
        (procedure_keyword)
        name: (identifier)
        (code_block
          (call_expression
            function: (identifier)
            arguments: (argument_list
              (string_literal)))))
      (preproc_endif))))

================================================================================
Table with mixed procedures and triggers in preprocessor
================================================================================

table 50103 "Test Table"
{
    fields
    {
        field(1; "No."; Code[20])
        {
            Caption = 'No.';
        }
    }

#if not CLEAN26
    trigger OnInsert()
    begin
        TestNoSeries();
    end;

    [Obsolete('Deprecated', '26.0')]
    procedure TestNoSeries()
    begin
        // Test implementation
    end;
#endif

    trigger OnModify()
    begin
        TestModified := true;
    end;
}

--------------------------------------------------------------------------------

(source_file
  (table_declaration
    (table_keyword)
    object_id: (integer)
    object_name: (quoted_identifier)
    (fields_section
      (fields_keyword)
      (field_declaration
        id: (integer)
        name: (quoted_identifier)
        type: (type_specification
          (code_type
            length: (integer)))
        (property
          name: (property_name)
          value: (string_literal))))
    (preproc_conditional
      (preproc_if
        condition: (preproc_not_expression
          (identifier)))
      (trigger_declaration
        (trigger_keyword)
        name: (identifier)
        (code_block
          (call_expression
            function: (identifier)
            arguments: (argument_list))))
      (attribute_item
        attribute: (attribute_content
          name: (identifier)
          arguments: (attribute_arguments
            (attribute_argument_list
              (string_literal)
              (string_literal)))))
      (procedure
        (procedure_keyword)
        name: (identifier)
        (code_block
          (comment)))
      (preproc_endif))
    (trigger_declaration
      (trigger_keyword)
      name: (identifier)
      (code_block
        (assignment_statement
          left: (identifier)
          right: (boolean))))))

================================================================================
Table with procedure without attributes in preprocessor
================================================================================

table 50104 "Test Table"
{
#if not CLEAN25
    procedure SimpleOldProcedure()
    begin
        Message('Simple old procedure');
    end;
#endif
}

--------------------------------------------------------------------------------

(source_file
  (table_declaration
    (table_keyword)
    object_id: (integer)
    object_name: (quoted_identifier)
    (preproc_conditional
      (preproc_if
        condition: (preproc_not_expression
          (identifier)))
      (procedure
        (procedure_keyword)
        name: (identifier)
        (code_block
          (call_expression
            function: (identifier)
            arguments: (argument_list
              (string_literal)))))
      (preproc_endif))))
