<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

/**
 * Original thrift enum:-
 * TestEnum
 */
enum TestEnum: int {
  UNKNOWN = 0;
  NEW_VALUE = 1;
}

class TestEnum_TEnumStaticMetadata implements \IThriftEnumStaticMetadata {
  public static function getEnumMetadata()[]: \tmeta_ThriftEnum {
    return tmeta_ThriftEnum::fromShape(
      shape(
        "name" => "module.TestEnum",
        "elements" => dict[
          0 => "UNKNOWN",
          1 => "NEW_VALUE",
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TEnumAnnotations {
    return shape(
      'enum' => dict[],
      'constants' => dict[
      ],
    );
  }
}

enum TestUnionEnum: int {
  _EMPTY_ = 0;
  int_value = 1;
  str_value = 2;
  double_value = 3;
  list_of_strings = 4;
  map_of_string_to_ints = 5;
  struct_foo = 6;
}

/**
 * Original thrift struct:-
 * TestUnion
 */
class TestUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<TestUnionEnum> {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'int_value',
      'union' => true,
      'type' => \TType::I32,
    ),
    2 => shape(
      'var' => 'str_value',
      'union' => true,
      'type' => \TType::STRING,
    ),
    3 => shape(
      'var' => 'double_value',
      'union' => true,
      'type' => \TType::DOUBLE,
    ),
    4 => shape(
      'var' => 'list_of_strings',
      'union' => true,
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'collection',
    ),
    5 => shape(
      'var' => 'map_of_string_to_ints',
      'union' => true,
      'type' => \TType::MAP,
      'ktype' => \TType::STRING,
      'vtype' => \TType::I32,
      'key' => shape(
        'type' => \TType::STRING,
      ),
      'val' => shape(
        'type' => \TType::I32,
      ),
      'format' => 'collection',
    ),
    6 => shape(
      'var' => 'struct_foo',
      'union' => true,
      'type' => \TType::STRUCT,
      'class' => Foo::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'int_value' => 1,
    'str_value' => 2,
    'double_value' => 3,
    'list_of_strings' => 4,
    'map_of_string_to_ints' => 5,
    'struct_foo' => 6,
  ];

  const type TConstructorShape = shape(
    ?'int_value' => ?int,
    ?'str_value' => ?string,
    ?'double_value' => ?float,
    ?'list_of_strings' => ?Vector<string>,
    ?'map_of_string_to_ints' => ?Map<string, int>,
    ?'struct_foo' => ?Foo,
  );

  const int STRUCTURAL_ID = 872350750526219001;
  /**
   * Original thrift field:-
   * 1: i32 int_value
   */
  public ?int $int_value;
  /**
   * Original thrift field:-
   * 2: string str_value
   */
  public ?string $str_value;
  /**
   * Original thrift field:-
   * 3: double double_value
   */
  public ?float $double_value;
  /**
   * Original thrift field:-
   * 4: list<string> list_of_strings
   */
  public ?Vector<string> $list_of_strings;
  /**
   * Original thrift field:-
   * 5: map<string, i32> map_of_string_to_ints
   */
  public ?Map<string, int> $map_of_string_to_ints;
  /**
   * Original thrift field:-
   * 6: module.Foo struct_foo
   */
  public ?Foo $struct_foo;
  protected TestUnionEnum $_type = TestUnionEnum::_EMPTY_;

  public function __construct(?int $int_value = null, ?string $str_value = null, ?float $double_value = null, ?Vector<string> $list_of_strings = null, ?Map<string, int> $map_of_string_to_ints = null, ?Foo $struct_foo = null)[] {
    $this->_type = TestUnionEnum::_EMPTY_;
    if ($int_value !== null) {
      $this->int_value = $int_value;
      $this->_type = TestUnionEnum::int_value;
    }
    if ($str_value !== null) {
      $this->str_value = $str_value;
      $this->_type = TestUnionEnum::str_value;
    }
    if ($double_value !== null) {
      $this->double_value = $double_value;
      $this->_type = TestUnionEnum::double_value;
    }
    if ($list_of_strings !== null) {
      $this->list_of_strings = $list_of_strings;
      $this->_type = TestUnionEnum::list_of_strings;
    }
    if ($map_of_string_to_ints !== null) {
      $this->map_of_string_to_ints = $map_of_string_to_ints;
      $this->_type = TestUnionEnum::map_of_string_to_ints;
    }
    if ($struct_foo !== null) {
      $this->struct_foo = $struct_foo;
      $this->_type = TestUnionEnum::struct_foo;
    }
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'int_value'),
      Shapes::idx($shape, 'str_value'),
      Shapes::idx($shape, 'double_value'),
      Shapes::idx($shape, 'list_of_strings'),
      Shapes::idx($shape, 'map_of_string_to_ints'),
      Shapes::idx($shape, 'struct_foo'),
    );
  }

  public function getName()[]: string {
    return 'TestUnion';
  }

  public function getType()[]: TestUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case TestUnionEnum::int_value:
        $this->int_value = null;
        break;
      case TestUnionEnum::str_value:
        $this->str_value = null;
        break;
      case TestUnionEnum::double_value:
        $this->double_value = null;
        break;
      case TestUnionEnum::list_of_strings:
        $this->list_of_strings = null;
        break;
      case TestUnionEnum::map_of_string_to_ints:
        $this->map_of_string_to_ints = null;
        break;
      case TestUnionEnum::struct_foo:
        $this->struct_foo = null;
        break;
      case TestUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = TestUnionEnum::_EMPTY_;
  }

  public function set_int_value(int $int_value)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::int_value;
    $this->int_value = $int_value;
    return $this;
  }

  public function get_int_value()[]: ?int {
    return $this->int_value;
  }

  public function getx_int_value()[]: int {
    invariant(
      $this->_type === TestUnionEnum::int_value,
      'get_int_value called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->int_value as nonnull;
  }

  public function set_str_value(string $str_value)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::str_value;
    $this->str_value = $str_value;
    return $this;
  }

  public function get_str_value()[]: ?string {
    return $this->str_value;
  }

  public function getx_str_value()[]: string {
    invariant(
      $this->_type === TestUnionEnum::str_value,
      'get_str_value called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->str_value as nonnull;
  }

  public function set_double_value(float $double_value)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::double_value;
    $this->double_value = $double_value;
    return $this;
  }

  public function get_double_value()[]: ?float {
    return $this->double_value;
  }

  public function getx_double_value()[]: float {
    invariant(
      $this->_type === TestUnionEnum::double_value,
      'get_double_value called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->double_value as nonnull;
  }

  public function set_list_of_strings(Vector<string> $list_of_strings)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::list_of_strings;
    $this->list_of_strings = $list_of_strings;
    return $this;
  }

  public function get_list_of_strings()[]: ?Vector<string> {
    return $this->list_of_strings;
  }

  public function getx_list_of_strings()[]: Vector<string> {
    invariant(
      $this->_type === TestUnionEnum::list_of_strings,
      'get_list_of_strings called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->list_of_strings as nonnull;
  }

  public function set_map_of_string_to_ints(Map<string, int> $map_of_string_to_ints)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::map_of_string_to_ints;
    $this->map_of_string_to_ints = $map_of_string_to_ints;
    return $this;
  }

  public function get_map_of_string_to_ints()[]: ?Map<string, int> {
    return $this->map_of_string_to_ints;
  }

  public function getx_map_of_string_to_ints()[]: Map<string, int> {
    invariant(
      $this->_type === TestUnionEnum::map_of_string_to_ints,
      'get_map_of_string_to_ints called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->map_of_string_to_ints as nonnull;
  }

  public function set_struct_foo(Foo $struct_foo)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::struct_foo;
    $this->struct_foo = $struct_foo;
    return $this;
  }

  public function get_struct_foo()[]: ?Foo {
    return $this->struct_foo;
  }

  public function getx_struct_foo()[]: Foo {
    invariant(
      $this->_type === TestUnionEnum::struct_foo,
      'get_struct_foo called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->struct_foo as nonnull;
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.TestUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "int_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "str_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "double_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_of_strings",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_of_string_to_ints",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "module.Foo",
                      "underlyingType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "module.Foo",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "struct_foo",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift struct:-
 * Foo
 */
class Foo implements \IThriftSyncStruct, \IThriftStructMetadata {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'a',
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'collection',
    ),
    2 => shape(
      'var' => 'b',
      'type' => \TType::MAP,
      'ktype' => \TType::STRING,
      'vtype' => \TType::LST,
      'key' => shape(
        'type' => \TType::STRING,
      ),
      'val' => shape(
        'type' => \TType::LST,
        'etype' => \TType::SET,
        'elem' => shape(
          'type' => \TType::SET,
          'etype' => \TType::I32,
          'elem' => shape(
            'type' => \TType::I32,
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
      'format' => 'collection',
    ),
    3 => shape(
      'var' => 'c',
      'type' => \TType::I64,
    ),
    4 => shape(
      'var' => 'd',
      'type' => \TType::BOOL,
    ),
    5 => shape(
      'var' => 'str_value',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'a' => 1,
    'b' => 2,
    'c' => 3,
    'd' => 4,
    'str_value' => 5,
  ];

  const type TConstructorShape = shape(
    ?'a' => ?Vector<string>,
    ?'b' => ?Map<string, Vector<Set<int>>>,
    ?'c' => ?int,
    ?'d' => ?bool,
    ?'str_value' => ?string,
  );

  const int STRUCTURAL_ID = 5952652426480946901;
  /**
   * Original thrift field:-
   * 1: list<string> a
   */
  public Vector<string> $a;
  /**
   * Original thrift field:-
   * 2: map<string, list<set<i32>>> b
   */
  public ?Map<string, Vector<Set<int>>> $b;
  /**
   * Original thrift field:-
   * 3: i64 c
   */
  public int $c;
  /**
   * Original thrift field:-
   * 4: bool d
   */
  public bool $d;
  /**
   * Original thrift field:-
   * 5: string str_value
   */
  public string $str_value;

  public function __construct(?Vector<string> $a = null, ?Map<string, Vector<Set<int>>> $b = null, ?int $c = null, ?bool $d = null, ?string $str_value = null)[] {
    $this->a = $a ?? Vector {};
    $this->b = $b;
    $this->c = $c ?? 7;
    $this->d = $d ?? false;
    $this->str_value = $str_value ?? "hello";
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'a'),
      Shapes::idx($shape, 'b'),
      Shapes::idx($shape, 'c'),
      Shapes::idx($shape, 'd'),
      Shapes::idx($shape, 'str_value'),
    );
  }

  public function getName()[]: string {
    return 'Foo';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.Foo",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "a",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_list" => tmeta_ThriftListType::fromShape(
                            shape(
                              "valueType" => tmeta_ThriftType::fromShape(
                                shape(
                                  "t_set" => tmeta_ThriftSetType::fromShape(
                                    shape(
                                      "valueType" => tmeta_ThriftType::fromShape(
                                        shape(
                                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                                        )
                                      ),
                                    )
                                  ),
                                )
                              ),
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "b",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "c",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE,
                )
              ),
              "name" => "d",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "str_value",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift struct:-
 * TestStruct
 */
class TestStruct implements \IThriftSyncStruct, \IThriftStructMetadata {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'foo_struct',
      'type' => \TType::STRUCT,
      'class' => Foo::class,
    ),
    2 => shape(
      'var' => 'union_value',
      'type' => \TType::STRUCT,
      'class' => TestUnion::class,
    ),
    3 => shape(
      'var' => 'struct_of_self',
      'type' => \TType::STRUCT,
      'class' => TestStruct::class,
    ),
    4 => shape(
      'var' => 'list_of_struct_foo',
      'type' => \TType::LST,
      'etype' => \TType::STRUCT,
      'elem' => shape(
        'type' => \TType::STRUCT,
        'class' => Foo::class,
      ),
      'format' => 'collection',
    ),
    5 => shape(
      'var' => 'map_of_string_to_struct_foo',
      'type' => \TType::MAP,
      'ktype' => \TType::STRING,
      'vtype' => \TType::STRUCT,
      'key' => shape(
        'type' => \TType::STRING,
      ),
      'val' => shape(
        'type' => \TType::STRUCT,
        'class' => Foo::class,
      ),
      'format' => 'collection',
    ),
    6 => shape(
      'var' => 'list_of_struct_self',
      'type' => \TType::LST,
      'etype' => \TType::STRUCT,
      'elem' => shape(
        'type' => \TType::STRUCT,
        'class' => TestStruct::class,
      ),
      'format' => 'collection',
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'foo_struct' => 1,
    'union_value' => 2,
    'struct_of_self' => 3,
    'list_of_struct_foo' => 4,
    'map_of_string_to_struct_foo' => 5,
    'list_of_struct_self' => 6,
  ];

  const type TConstructorShape = shape(
    ?'foo_struct' => ?Foo,
    ?'union_value' => ?TestUnion,
    ?'struct_of_self' => ?TestStruct,
    ?'list_of_struct_foo' => ?Vector<Foo>,
    ?'map_of_string_to_struct_foo' => ?Map<string, Foo>,
    ?'list_of_struct_self' => ?Vector<TestStruct>,
  );

  const int STRUCTURAL_ID = 6681594433718475023;
  /**
   * Original thrift field:-
   * 1: module.Foo foo_struct
   */
  public ?Foo $foo_struct;
  /**
   * Original thrift field:-
   * 2: module.TestUnion union_value
   */
  public ?TestUnion $union_value;
  /**
   * Original thrift field:-
   * 3: module.TestStruct struct_of_self
   */
  public ?TestStruct $struct_of_self;
  /**
   * Original thrift field:-
   * 4: list<module.Foo> list_of_struct_foo
   */
  public Vector<Foo> $list_of_struct_foo;
  /**
   * Original thrift field:-
   * 5: map<string, module.Foo> map_of_string_to_struct_foo
   */
  public Map<string, Foo> $map_of_string_to_struct_foo;
  /**
   * Original thrift field:-
   * 6: list<module.TestStruct> list_of_struct_self
   */
  public Vector<TestStruct> $list_of_struct_self;

  public function __construct(?Foo $foo_struct = null, ?TestUnion $union_value = null, ?TestStruct $struct_of_self = null, ?Vector<Foo> $list_of_struct_foo = null, ?Map<string, Foo> $map_of_string_to_struct_foo = null, ?Vector<TestStruct> $list_of_struct_self = null)[] {
    $this->foo_struct = $foo_struct;
    $this->union_value = $union_value;
    $this->struct_of_self = $struct_of_self;
    $this->list_of_struct_foo = $list_of_struct_foo ?? Vector {};
    $this->map_of_string_to_struct_foo = $map_of_string_to_struct_foo ?? Map {};
    $this->list_of_struct_self = $list_of_struct_self ?? Vector {};
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'foo_struct'),
      Shapes::idx($shape, 'union_value'),
      Shapes::idx($shape, 'struct_of_self'),
      Shapes::idx($shape, 'list_of_struct_foo'),
      Shapes::idx($shape, 'map_of_string_to_struct_foo'),
      Shapes::idx($shape, 'list_of_struct_self'),
    );
  }

  public function getName()[]: string {
    return 'TestStruct';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.TestStruct",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.Foo",
                    )
                  ),
                )
              ),
              "name" => "foo_struct",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.TestUnion",
                    )
                  ),
                )
              ),
              "name" => "union_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "module.TestStruct",
                      "underlyingType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "module.TestStruct",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "struct_of_self",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "module.Foo",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_of_struct_foo",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "module.Foo",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_of_string_to_struct_foo",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                            shape(
                              "name" => "module.TestStruct",
                              "underlyingType" => tmeta_ThriftType::fromShape(
                                shape(
                                  "t_struct" => tmeta_ThriftStructType::fromShape(
                                    shape(
                                      "name" => "module.TestStruct",
                                    )
                                  ),
                                )
                              ),
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_of_struct_self",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift exception:-
 * Baz
 */
class Baz extends \TException implements \IThriftSyncStruct, \IThriftExceptionMetadata {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'message',
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'some_field',
      'type' => \TType::STRUCT,
      'class' => Foo::class,
    ),
    3 => shape(
      'var' => 'some_container',
      'type' => \TType::SET,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'collection',
    ),
    4 => shape(
      'var' => 'code',
      'type' => \TType::I32,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'message' => 1,
    'some_field' => 2,
    'some_container' => 3,
    'code' => 4,
  ];

  const type TConstructorShape = shape(
    ?'message' => ?string,
    ?'some_field' => ?Foo,
    ?'some_container' => ?Set<string>,
    ?'code' => ?int,
  );

  const int STRUCTURAL_ID = 1663976252517274137;
  /**
   * Original thrift field:-
   * 1: string message
   */
  public string $message;
  /**
   * Original thrift field:-
   * 2: module.Foo some_field
   */
  public ?Foo $some_field;
  /**
   * Original thrift field:-
   * 3: set<string> some_container
   */
  public Set<string> $some_container;
  /**
   * Original thrift field:-
   * 4: i32 code
   */
  public int $code;

  public function __construct(?string $message = null, ?Foo $some_field = null, ?Set<string> $some_container = null, ?int $code = null)[] {
    parent::__construct();
    $this->message = $message ?? '';
    $this->some_field = $some_field;
    $this->some_container = $some_container ?? Set {};
    $this->code = $code ?? 0;
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'message'),
      Shapes::idx($shape, 'some_field'),
      Shapes::idx($shape, 'some_container'),
      Shapes::idx($shape, 'code'),
    );
  }

  public function getName()[]: string {
    return 'Baz';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getExceptionMetadata()[]: \tmeta_ThriftException {
    return tmeta_ThriftException::fromShape(
      shape(
        "name" => "module.Baz",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "message",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.Foo",
                    )
                  ),
                )
              ),
              "name" => "some_field",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "some_container",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "code",
            )
          ),
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift exception:-
 * OptBaz
 */
class OptBaz extends \TException implements \IThriftSyncStruct, \IThriftExceptionMetadata {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'message',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'message' => 1,
  ];

  const type TConstructorShape = shape(
    ?'message' => ?string,
  );

  const int STRUCTURAL_ID = 546500496397478593;
  /**
   * Original thrift field:-
   * 1: string message
   */
  public string $message;

  public function __construct(?string $message = null)[] {
    parent::__construct();
    $this->message = $message ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'message'),
    );
  }

  public function getName()[]: string {
    return 'OptBaz';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getExceptionMetadata()[]: \tmeta_ThriftException {
    return tmeta_ThriftException::fromShape(
      shape(
        "name" => "module.OptBaz",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "message",
              "is_optional" => true,
            )
          ),
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}


<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

/**
 * Original thrift service:-
 * Bar
 */
interface BarAsyncIf extends \IThriftAsyncIf {
  /**
   * Original thrift definition:-
   * string
   *   baz(1: set<i32> a,
   *       2: list<map<i32, set<string>>> b,
   *       3: i64 c,
   *       4: Foo d,
   *       5: i64 e);
   */
  public function baz(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): Awaitable<string>;
}

/**
 * Original thrift service:-
 * Bar
 */
interface BarIf extends \IThriftSyncIf {
  /**
   * Original thrift definition:-
   * string
   *   baz(1: set<i32> a,
   *       2: list<map<i32, set<string>>> b,
   *       3: i64 c,
   *       4: Foo d,
   *       5: i64 e);
   */
  public function baz(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): string;
}

/**
 * Original thrift service:-
 * Bar
 */
interface BarAsyncClientIf extends BarAsyncIf {
}

/**
 * Original thrift service:-
 * Bar
 */
interface BarClientIf extends \IThriftSyncIf {
  /**
   * Original thrift definition:-
   * string
   *   baz(1: set<i32> a,
   *       2: list<map<i32, set<string>>> b,
   *       3: i64 c,
   *       4: Foo d,
   *       5: i64 e);
   */
  public function baz(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): Awaitable<string>;
}

/**
 * Original thrift service:-
 * Bar
 */
trait BarClientBase {
  require extends \ThriftClientBase;

}

class BarAsyncClient extends \ThriftClientBase implements BarAsyncClientIf {
  use BarClientBase;

  /**
   * Original thrift definition:-
   * string
   *   baz(1: set<i32> a,
   *       2: list<map<i32, set<string>>> b,
   *       3: i64 c,
   *       4: Foo d,
   *       5: i64 e);
   */
  public async function baz(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): Awaitable<string> {
    $hh_frame_metadata = $this->getHHFrameMetadata();
    if ($hh_frame_metadata !== null) {
      \HH\set_frame_metadata($hh_frame_metadata);
    }
    $rpc_options = $this->getAndResetOptions() ?? \ThriftClientBase::defaultOptions();
    $args = Bar_baz_args::fromShape(shape(
      'a' => $a,
      'b' => Vec\map($b,
        $_val0 ==> dict($_val0)
      ),
      'c' => $c,
      'd' => $d,
      'e' => $e,
    ));
    await $this->asyncHandler_->genBefore("Bar", "baz", $args);
    $currentseqid = $this->sendImplHelper($args, "baz", false);
    return await $this->genAwaitResponse(Bar_baz_result::class, "baz", false, $currentseqid, $rpc_options);
  }

  /**
   * Original thrift definition:-
   * string
   *   baz(1: set<i32> a,
   *       2: list<map<i32, set<string>>> b,
   *       3: i64 c,
   *       4: Foo d,
   *       5: i64 e);
   */
  public async function baz__LEGACY_ARRAYS(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): Awaitable<string> {
    $hh_frame_metadata = $this->getHHFrameMetadata();
    if ($hh_frame_metadata !== null) {
      \HH\set_frame_metadata($hh_frame_metadata);
    }
    $rpc_options = $this->getAndResetOptions() ?? \ThriftClientBase::defaultOptions();
    $args = Bar_baz_args::fromShape(shape(
      'a' => $a,
      'b' => Vec\map($b,
        $_val0 ==> dict($_val0)
      ),
      'c' => $c,
      'd' => $d,
      'e' => $e,
    ));
    await $this->asyncHandler_->genBefore("Bar", "baz", $args);
    $currentseqid = $this->sendImplHelper($args, "baz", false);
    return await $this->genAwaitResponse(Bar_baz_result::class, "baz", false, $currentseqid, $rpc_options, shape('read_options' => \THRIFT_MARK_LEGACY_ARRAYS));
  }

}

class BarClient extends \ThriftClientBase implements BarClientIf {
  use BarClientBase;

  /**
   * Original thrift definition:-
   * string
   *   baz(1: set<i32> a,
   *       2: list<map<i32, set<string>>> b,
   *       3: i64 c,
   *       4: Foo d,
   *       5: i64 e);
   */
  public async function baz(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): Awaitable<string> {
    $hh_frame_metadata = $this->getHHFrameMetadata();
    if ($hh_frame_metadata !== null) {
      \HH\set_frame_metadata($hh_frame_metadata);
    }
    $rpc_options = $this->getAndResetOptions() ?? \ThriftClientBase::defaultOptions();
    $args = Bar_baz_args::fromShape(shape(
      'a' => $a,
      'b' => Vec\map($b,
        $_val0 ==> dict($_val0)
      ),
      'c' => $c,
      'd' => $d,
      'e' => $e,
    ));
    await $this->asyncHandler_->genBefore("Bar", "baz", $args);
    $currentseqid = $this->sendImplHelper($args, "baz", false);
    return await $this->genAwaitResponse(Bar_baz_result::class, "baz", false, $currentseqid, $rpc_options);
  }

  /**
   * Original thrift definition:-
   * string
   *   baz(1: set<i32> a,
   *       2: list<map<i32, set<string>>> b,
   *       3: i64 c,
   *       4: Foo d,
   *       5: i64 e);
   */
  public async function baz__LEGACY_ARRAYS(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): Awaitable<string> {
    $hh_frame_metadata = $this->getHHFrameMetadata();
    if ($hh_frame_metadata !== null) {
      \HH\set_frame_metadata($hh_frame_metadata);
    }
    $rpc_options = $this->getAndResetOptions() ?? \ThriftClientBase::defaultOptions();
    $args = Bar_baz_args::fromShape(shape(
      'a' => $a,
      'b' => Vec\map($b,
        $_val0 ==> dict($_val0)
      ),
      'c' => $c,
      'd' => $d,
      'e' => $e,
    ));
    await $this->asyncHandler_->genBefore("Bar", "baz", $args);
    $currentseqid = $this->sendImplHelper($args, "baz", false);
    return await $this->genAwaitResponse(Bar_baz_result::class, "baz", false, $currentseqid, $rpc_options, shape('read_options' => \THRIFT_MARK_LEGACY_ARRAYS));
  }

  /* send and recv functions */
  public function send_baz(dict<int, bool> $a, KeyedContainer<int, KeyedContainer<int, dict<string, bool>>> $b, int $c, ?Foo $d, int $e): int {
    $args = Bar_baz_args::fromShape(shape(
      'a' => $a,
      'b' => Vec\map($b,
        $_val0 ==> dict($_val0)
      ),
      'c' => $c,
      'd' => $d,
      'e' => $e,
    ));
    return $this->sendImplHelper($args, "baz", false);
  }
  public function recv_baz(?int $expectedsequenceid = null): string {
    return $this->recvImplHelper(Bar_baz_result::class, "baz", false, $expectedsequenceid);
  }
}

// HELPER FUNCTIONS AND STRUCTURES

class Bar_baz_args implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'a',
      'type' => \TType::SET,
      'etype' => \TType::I32,
      'elem' => shape(
        'type' => \TType::I32,
      ),
      'format' => 'array',
    ),
    2 => shape(
      'var' => 'b',
      'type' => \TType::LST,
      'etype' => \TType::MAP,
      'elem' => shape(
        'type' => \TType::MAP,
        'ktype' => \TType::I32,
        'vtype' => \TType::SET,
        'key' => shape(
          'type' => \TType::I32,
        ),
        'val' => shape(
          'type' => \TType::SET,
          'etype' => \TType::STRING,
          'elem' => shape(
            'type' => \TType::STRING,
          ),
          'format' => 'array',
        ),
        'format' => 'array',
      ),
      'format' => 'array',
    ),
    3 => shape(
      'var' => 'c',
      'type' => \TType::I64,
    ),
    4 => shape(
      'var' => 'd',
      'type' => \TType::STRUCT,
      'class' => Foo::class,
    ),
    5 => shape(
      'var' => 'e',
      'type' => \TType::I64,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'a' => 1,
    'b' => 2,
    'c' => 3,
    'd' => 4,
    'e' => 5,
  ];

  const type TConstructorShape = shape(
    ?'a' => ?dict<int, bool>,
    ?'b' => ?varray<darray<int, dict<string, bool>>>,
    ?'c' => ?int,
    ?'d' => ?Foo,
    ?'e' => ?int,
  );

  const type TShape = shape(
    'a' => dict<int, bool>,
    'b' => varray<darray<int, dict<string, bool>>>,
    'c' => int,
    ?'d' => ?Foo::TShape,
    'e' => int,
  );
  const int STRUCTURAL_ID = 7865027497865509792;
  public dict<int, bool> $a;
  public vec<dict<int, dict<string, bool>>> $b;
  public int $c;
  public ?Foo $d;
  public int $e;

  public function __construct(?dict<int, bool> $a = null, ?vec<dict<int, dict<string, bool>>> $b = null, ?int $c = null, ?Foo $d = null, ?int $e = null)[] {
    $this->a = $a ?? dict[];
    $this->b = $b ?? vec[];
    $this->c = $c ?? 0;
    $this->d = $d;
    $this->e = $e ?? 4;
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'a'),
      Shapes::idx($shape, 'b'),
      Shapes::idx($shape, 'c'),
      Shapes::idx($shape, 'd'),
      Shapes::idx($shape, 'e'),
    );
  }

  public function getName()[]: string {
    return 'Bar_baz_args';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.baz_args",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "a",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_map" => tmeta_ThriftMapType::fromShape(
                            shape(
                              "keyType" => tmeta_ThriftType::fromShape(
                                shape(
                                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                                )
                              ),
                              "valueType" => tmeta_ThriftType::fromShape(
                                shape(
                                  "t_set" => tmeta_ThriftSetType::fromShape(
                                    shape(
                                      "valueType" => tmeta_ThriftType::fromShape(
                                        shape(
                                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                                        )
                                      ),
                                    )
                                  ),
                                )
                              ),
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "b",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "c",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.Foo",
                    )
                  ),
                )
              ),
              "name" => "d",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "e",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['a'],
      $shape['b'],
      $shape['c'],
      Shapes::idx($shape, 'd') === null ? null : (Foo::__fromShape($shape['d'])),
      $shape['e'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'a' => $this->a,
      'b' => $this->b,
      'c' => $this->c,
      'd' => $this->d?->__toShape(),
      'e' => $this->e,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

class Bar_baz_result extends \ThriftSyncStructWithResult implements \IThriftStructMetadata {
  use \ThriftSerializationTrait;

  const type TResult = string;

  const \ThriftStructTypes::TSpec SPEC = dict[
    0 => shape(
      'var' => 'success',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'success' => 0,
  ];

  const type TConstructorShape = shape(
    ?'success' => ?this::TResult,
  );

  const int STRUCTURAL_ID = 1365128170602685579;
  public ?this::TResult $success;

  public function __construct(?this::TResult $success = null)[] {
    $this->success = $success;
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'success'),
    );
  }

  public function getName()[]: string {
    return 'Bar_baz_result';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.Bar_baz_result",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 0,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "success",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

class BarStaticMetadata implements \IThriftServiceStaticMetadata {
  public static function getServiceMetadata()[]: \tmeta_ThriftService {
    return tmeta_ThriftService::fromShape(
      shape(
        "name" => "module.Bar",
        "functions" => vec[
          tmeta_ThriftFunction::fromShape(
            shape(
              "name" => "baz",
              "return_type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "arguments" => vec[
                tmeta_ThriftField::fromShape(
                  shape(
                    "id" => 1,
                    "type" => tmeta_ThriftType::fromShape(
                      shape(
                        "t_set" => tmeta_ThriftSetType::fromShape(
                          shape(
                            "valueType" => tmeta_ThriftType::fromShape(
                              shape(
                                "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                              )
                            ),
                          )
                        ),
                      )
                    ),
                    "name" => "a",
                  )
                ),
                tmeta_ThriftField::fromShape(
                  shape(
                    "id" => 2,
                    "type" => tmeta_ThriftType::fromShape(
                      shape(
                        "t_list" => tmeta_ThriftListType::fromShape(
                          shape(
                            "valueType" => tmeta_ThriftType::fromShape(
                              shape(
                                "t_map" => tmeta_ThriftMapType::fromShape(
                                  shape(
                                    "keyType" => tmeta_ThriftType::fromShape(
                                      shape(
                                        "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                                      )
                                    ),
                                    "valueType" => tmeta_ThriftType::fromShape(
                                      shape(
                                        "t_set" => tmeta_ThriftSetType::fromShape(
                                          shape(
                                            "valueType" => tmeta_ThriftType::fromShape(
                                              shape(
                                                "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                                              )
                                            ),
                                          )
                                        ),
                                      )
                                    ),
                                  )
                                ),
                              )
                            ),
                          )
                        ),
                      )
                    ),
                    "name" => "b",
                  )
                ),
                tmeta_ThriftField::fromShape(
                  shape(
                    "id" => 3,
                    "type" => tmeta_ThriftType::fromShape(
                      shape(
                        "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                      )
                    ),
                    "name" => "c",
                  )
                ),
                tmeta_ThriftField::fromShape(
                  shape(
                    "id" => 4,
                    "type" => tmeta_ThriftType::fromShape(
                      shape(
                        "t_struct" => tmeta_ThriftStructType::fromShape(
                          shape(
                            "name" => "module.Foo",
                          )
                        ),
                      )
                    ),
                    "name" => "d",
                  )
                ),
                tmeta_ThriftField::fromShape(
                  shape(
                    "id" => 5,
                    "type" => tmeta_ThriftType::fromShape(
                      shape(
                        "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                      )
                    ),
                    "name" => "e",
                  )
                ),
              ],
            )
          ),
        ],
      )
    );
  }

  public static function getServiceMetadataResponse()[]: \tmeta_ThriftServiceMetadataResponse {
    return \tmeta_ThriftServiceMetadataResponse::fromShape(
      shape(
        'context' => \tmeta_ThriftServiceContext::fromShape(
          shape(
            'service_info' => self::getServiceMetadata(),
            'module' => \tmeta_ThriftModuleContext::fromShape(
              shape(
                'name' => 'module',
              )
            ),
          )
        ),
        'metadata' => \tmeta_ThriftMetadata::fromShape(
          shape(
            'enums' => dict[
            ],
            'structs' => dict[
              'module.Foo' => Foo::getStructMetadata(),
            ],
            'exceptions' => dict[
            ],
            'services' => dict[
            ],
          )
        ),
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TServiceAnnotations {
    return shape(
      'service' => dict[],
      'functions' => dict[
      ],
    );
  }
}


<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

/**
 * Original thrift enum:-
 * TestEnum
 */
enum TestEnum: int {
  UNKNOWN = 0;
  NEW_VALUE = 1;
}

class TestEnum_TEnumStaticMetadata implements \IThriftEnumStaticMetadata {
  public static function getEnumMetadata()[]: \tmeta_ThriftEnum {
    return tmeta_ThriftEnum::fromShape(
      shape(
        "name" => "module.TestEnum",
        "elements" => dict[
          0 => "UNKNOWN",
          1 => "NEW_VALUE",
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TEnumAnnotations {
    return shape(
      'enum' => dict[],
      'constants' => dict[
      ],
    );
  }
}

enum TestUnionEnum: int {
  _EMPTY_ = 0;
  int_value = 1;
  str_value = 2;
  double_value = 3;
  list_of_strings = 4;
  map_of_string_to_ints = 5;
  struct_foo = 6;
}

/**
 * Original thrift struct:-
 * TestUnion
 */
class TestUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<TestUnionEnum>, \IThriftShapishSyncStruct {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'int_value',
      'union' => true,
      'type' => \TType::I32,
    ),
    2 => shape(
      'var' => 'str_value',
      'union' => true,
      'type' => \TType::STRING,
    ),
    3 => shape(
      'var' => 'double_value',
      'union' => true,
      'type' => \TType::DOUBLE,
    ),
    4 => shape(
      'var' => 'list_of_strings',
      'union' => true,
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'array',
    ),
    5 => shape(
      'var' => 'map_of_string_to_ints',
      'union' => true,
      'type' => \TType::MAP,
      'ktype' => \TType::STRING,
      'vtype' => \TType::I32,
      'key' => shape(
        'type' => \TType::STRING,
      ),
      'val' => shape(
        'type' => \TType::I32,
      ),
      'format' => 'array',
    ),
    6 => shape(
      'var' => 'struct_foo',
      'union' => true,
      'type' => \TType::STRUCT,
      'class' => Foo::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'int_value' => 1,
    'str_value' => 2,
    'double_value' => 3,
    'list_of_strings' => 4,
    'map_of_string_to_ints' => 5,
    'struct_foo' => 6,
  ];

  const type TConstructorShape = shape(
    ?'int_value' => ?int,
    ?'str_value' => ?string,
    ?'double_value' => ?float,
    ?'list_of_strings' => ?varray<string>,
    ?'map_of_string_to_ints' => ?darray<string, int>,
    ?'struct_foo' => ?Foo,
  );

  const type TShape = shape(
    ?'int_value' => ?int,
    ?'str_value' => ?string,
    ?'double_value' => ?float,
    ?'list_of_strings' => ?varray<string>,
    ?'map_of_string_to_ints' => ?darray<string, int>,
    ?'struct_foo' => ?Foo::TShape,
  );
  const int STRUCTURAL_ID = 872350750526219001;
  /**
   * Original thrift field:-
   * 1: i32 int_value
   */
  public ?int $int_value;
  /**
   * Original thrift field:-
   * 2: string str_value
   */
  public ?string $str_value;
  /**
   * Original thrift field:-
   * 3: double double_value
   */
  public ?float $double_value;
  /**
   * Original thrift field:-
   * 4: list<string> list_of_strings
   */
  public ?vec<string> $list_of_strings;
  /**
   * Original thrift field:-
   * 5: map<string, i32> map_of_string_to_ints
   */
  public ?dict<string, int> $map_of_string_to_ints;
  /**
   * Original thrift field:-
   * 6: module.Foo struct_foo
   */
  public ?Foo $struct_foo;
  protected TestUnionEnum $_type = TestUnionEnum::_EMPTY_;

  public function __construct(?int $int_value = null, ?string $str_value = null, ?float $double_value = null, ?vec<string> $list_of_strings = null, ?dict<string, int> $map_of_string_to_ints = null, ?Foo $struct_foo = null)[] {
    $this->_type = TestUnionEnum::_EMPTY_;
    if ($int_value !== null) {
      $this->int_value = $int_value;
      $this->_type = TestUnionEnum::int_value;
    }
    if ($str_value !== null) {
      $this->str_value = $str_value;
      $this->_type = TestUnionEnum::str_value;
    }
    if ($double_value !== null) {
      $this->double_value = $double_value;
      $this->_type = TestUnionEnum::double_value;
    }
    if ($list_of_strings !== null) {
      $this->list_of_strings = $list_of_strings;
      $this->_type = TestUnionEnum::list_of_strings;
    }
    if ($map_of_string_to_ints !== null) {
      $this->map_of_string_to_ints = $map_of_string_to_ints;
      $this->_type = TestUnionEnum::map_of_string_to_ints;
    }
    if ($struct_foo !== null) {
      $this->struct_foo = $struct_foo;
      $this->_type = TestUnionEnum::struct_foo;
    }
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'int_value'),
      Shapes::idx($shape, 'str_value'),
      Shapes::idx($shape, 'double_value'),
      Shapes::idx($shape, 'list_of_strings'),
      Shapes::idx($shape, 'map_of_string_to_ints'),
      Shapes::idx($shape, 'struct_foo'),
    );
  }

  public function getName()[]: string {
    return 'TestUnion';
  }

  public function getType()[]: TestUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case TestUnionEnum::int_value:
        $this->int_value = null;
        break;
      case TestUnionEnum::str_value:
        $this->str_value = null;
        break;
      case TestUnionEnum::double_value:
        $this->double_value = null;
        break;
      case TestUnionEnum::list_of_strings:
        $this->list_of_strings = null;
        break;
      case TestUnionEnum::map_of_string_to_ints:
        $this->map_of_string_to_ints = null;
        break;
      case TestUnionEnum::struct_foo:
        $this->struct_foo = null;
        break;
      case TestUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = TestUnionEnum::_EMPTY_;
  }

  public function set_int_value(int $int_value)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::int_value;
    $this->int_value = $int_value;
    return $this;
  }

  public function get_int_value()[]: ?int {
    return $this->int_value;
  }

  public function getx_int_value()[]: int {
    invariant(
      $this->_type === TestUnionEnum::int_value,
      'get_int_value called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->int_value as nonnull;
  }

  public function set_str_value(string $str_value)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::str_value;
    $this->str_value = $str_value;
    return $this;
  }

  public function get_str_value()[]: ?string {
    return $this->str_value;
  }

  public function getx_str_value()[]: string {
    invariant(
      $this->_type === TestUnionEnum::str_value,
      'get_str_value called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->str_value as nonnull;
  }

  public function set_double_value(float $double_value)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::double_value;
    $this->double_value = $double_value;
    return $this;
  }

  public function get_double_value()[]: ?float {
    return $this->double_value;
  }

  public function getx_double_value()[]: float {
    invariant(
      $this->_type === TestUnionEnum::double_value,
      'get_double_value called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->double_value as nonnull;
  }

  public function set_list_of_strings(vec<string> $list_of_strings)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::list_of_strings;
    $this->list_of_strings = $list_of_strings;
    return $this;
  }

  public function get_list_of_strings()[]: ?vec<string> {
    return $this->list_of_strings;
  }

  public function getx_list_of_strings()[]: vec<string> {
    invariant(
      $this->_type === TestUnionEnum::list_of_strings,
      'get_list_of_strings called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->list_of_strings as nonnull;
  }

  public function set_map_of_string_to_ints(dict<string, int> $map_of_string_to_ints)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::map_of_string_to_ints;
    $this->map_of_string_to_ints = $map_of_string_to_ints;
    return $this;
  }

  public function get_map_of_string_to_ints()[]: ?dict<string, int> {
    return $this->map_of_string_to_ints;
  }

  public function getx_map_of_string_to_ints()[]: dict<string, int> {
    invariant(
      $this->_type === TestUnionEnum::map_of_string_to_ints,
      'get_map_of_string_to_ints called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->map_of_string_to_ints as nonnull;
  }

  public function set_struct_foo(Foo $struct_foo)[write_props]: this {
    $this->reset();
    $this->_type = TestUnionEnum::struct_foo;
    $this->struct_foo = $struct_foo;
    return $this;
  }

  public function get_struct_foo()[]: ?Foo {
    return $this->struct_foo;
  }

  public function getx_struct_foo()[]: Foo {
    invariant(
      $this->_type === TestUnionEnum::struct_foo,
      'get_struct_foo called on an instance of TestUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->struct_foo as nonnull;
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.TestUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "int_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "str_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "double_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_of_strings",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_of_string_to_ints",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "module.Foo",
                      "underlyingType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "module.Foo",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "struct_foo",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'int_value'),
      Shapes::idx($shape, 'str_value'),
      Shapes::idx($shape, 'double_value'),
      Shapes::idx($shape, 'list_of_strings'),
      Shapes::idx($shape, 'map_of_string_to_ints'),
      Shapes::idx($shape, 'struct_foo') === null ? null : (Foo::__fromShape($shape['struct_foo'])),
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'int_value' => $this->int_value,
      'str_value' => $this->str_value,
      'double_value' => $this->double_value,
      'list_of_strings' => $this->list_of_strings,
      'map_of_string_to_ints' => $this->map_of_string_to_ints,
      'struct_foo' => $this->struct_foo?->__toShape(),
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift struct:-
 * Foo
 */
class Foo implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'a',
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'array',
    ),
    2 => shape(
      'var' => 'b',
      'type' => \TType::MAP,
      'ktype' => \TType::STRING,
      'vtype' => \TType::LST,
      'key' => shape(
        'type' => \TType::STRING,
      ),
      'val' => shape(
        'type' => \TType::LST,
        'etype' => \TType::SET,
        'elem' => shape(
          'type' => \TType::SET,
          'etype' => \TType::I32,
          'elem' => shape(
            'type' => \TType::I32,
          ),
          'format' => 'array',
        ),
        'format' => 'array',
      ),
      'format' => 'array',
    ),
    3 => shape(
      'var' => 'c',
      'type' => \TType::I64,
    ),
    4 => shape(
      'var' => 'd',
      'type' => \TType::BOOL,
    ),
    5 => shape(
      'var' => 'str_value',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'a' => 1,
    'b' => 2,
    'c' => 3,
    'd' => 4,
    'str_value' => 5,
  ];

  const type TConstructorShape = shape(
    ?'a' => ?varray<string>,
    ?'b' => ?darray<string, varray<dict<int, bool>>>,
    ?'c' => ?int,
    ?'d' => ?bool,
    ?'str_value' => ?string,
  );

  const type TShape = shape(
    'a' => varray<string>,
    ?'b' => ?darray<string, varray<dict<int, bool>>>,
    'c' => int,
    'd' => bool,
    'str_value' => string,
  );
  const int STRUCTURAL_ID = 5952652426480946901;
  /**
   * Original thrift field:-
   * 1: list<string> a
   */
  public vec<string> $a;
  /**
   * Original thrift field:-
   * 2: map<string, list<set<i32>>> b
   */
  public ?dict<string, vec<dict<int, bool>>> $b;
  /**
   * Original thrift field:-
   * 3: i64 c
   */
  public int $c;
  /**
   * Original thrift field:-
   * 4: bool d
   */
  public bool $d;
  /**
   * Original thrift field:-
   * 5: string str_value
   */
  public string $str_value;

  public function __construct(?vec<string> $a = null, ?dict<string, vec<dict<int, bool>>> $b = null, ?int $c = null, ?bool $d = null, ?string $str_value = null)[] {
    $this->a = $a ?? vec[];
    $this->b = $b;
    $this->c = $c ?? 7;
    $this->d = $d ?? false;
    $this->str_value = $str_value ?? "hello";
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'a'),
      Shapes::idx($shape, 'b'),
      Shapes::idx($shape, 'c'),
      Shapes::idx($shape, 'd'),
      Shapes::idx($shape, 'str_value'),
    );
  }

  public function getName()[]: string {
    return 'Foo';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.Foo",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "a",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_list" => tmeta_ThriftListType::fromShape(
                            shape(
                              "valueType" => tmeta_ThriftType::fromShape(
                                shape(
                                  "t_set" => tmeta_ThriftSetType::fromShape(
                                    shape(
                                      "valueType" => tmeta_ThriftType::fromShape(
                                        shape(
                                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                                        )
                                      ),
                                    )
                                  ),
                                )
                              ),
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "b",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "c",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE,
                )
              ),
              "name" => "d",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "str_value",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['a'],
      Shapes::idx($shape, 'b'),
      $shape['c'],
      $shape['d'],
      $shape['str_value'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'a' => $this->a,
      'b' => $this->b,
      'c' => $this->c,
      'd' => $this->d,
      'str_value' => $this->str_value,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift struct:-
 * TestStruct
 */
class TestStruct implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'foo_struct',
      'type' => \TType::STRUCT,
      'class' => Foo::class,
    ),
    2 => shape(
      'var' => 'union_value',
      'type' => \TType::STRUCT,
      'class' => TestUnion::class,
    ),
    4 => shape(
      'var' => 'list_of_struct_foo',
      'type' => \TType::LST,
      'etype' => \TType::STRUCT,
      'elem' => shape(
        'type' => \TType::STRUCT,
        'class' => Foo::class,
      ),
      'format' => 'array',
    ),
    5 => shape(
      'var' => 'map_of_string_to_struct_foo',
      'type' => \TType::MAP,
      'ktype' => \TType::STRING,
      'vtype' => \TType::STRUCT,
      'key' => shape(
        'type' => \TType::STRING,
      ),
      'val' => shape(
        'type' => \TType::STRUCT,
        'class' => Foo::class,
      ),
      'format' => 'array',
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'foo_struct' => 1,
    'union_value' => 2,
    'list_of_struct_foo' => 4,
    'map_of_string_to_struct_foo' => 5,
  ];

  const type TConstructorShape = shape(
    ?'foo_struct' => ?Foo,
    ?'union_value' => ?TestUnion,
    ?'list_of_struct_foo' => ?varray<Foo>,
    ?'map_of_string_to_struct_foo' => ?darray<string, Foo>,
  );

  const type TShape = shape(
    ?'foo_struct' => ?Foo::TShape,
    ?'union_value' => ?TestUnion::TShape,
    'list_of_struct_foo' => varray<Foo::TShape>,
    'map_of_string_to_struct_foo' => darray<string, Foo::TShape>,
  );
  const int STRUCTURAL_ID = 6061345478592222801;
  /**
   * Original thrift field:-
   * 1: module.Foo foo_struct
   */
  public ?Foo $foo_struct;
  /**
   * Original thrift field:-
   * 2: module.TestUnion union_value
   */
  public ?TestUnion $union_value;
  /**
   * Original thrift field:-
   * 4: list<module.Foo> list_of_struct_foo
   */
  public vec<Foo> $list_of_struct_foo;
  /**
   * Original thrift field:-
   * 5: map<string, module.Foo> map_of_string_to_struct_foo
   */
  public dict<string, Foo> $map_of_string_to_struct_foo;

  public function __construct(?Foo $foo_struct = null, ?TestUnion $union_value = null, ?vec<Foo> $list_of_struct_foo = null, ?dict<string, Foo> $map_of_string_to_struct_foo = null)[] {
    $this->foo_struct = $foo_struct;
    $this->union_value = $union_value;
    $this->list_of_struct_foo = $list_of_struct_foo ?? vec[];
    $this->map_of_string_to_struct_foo = $map_of_string_to_struct_foo ?? dict[];
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'foo_struct'),
      Shapes::idx($shape, 'union_value'),
      Shapes::idx($shape, 'list_of_struct_foo'),
      Shapes::idx($shape, 'map_of_string_to_struct_foo'),
    );
  }

  public function getName()[]: string {
    return 'TestStruct';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.TestStruct",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.Foo",
                    )
                  ),
                )
              ),
              "name" => "foo_struct",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.TestUnion",
                    )
                  ),
                )
              ),
              "name" => "union_value",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "module.Foo",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_of_struct_foo",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "module.Foo",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_of_string_to_struct_foo",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'foo_struct') === null ? null : (Foo::__fromShape($shape['foo_struct'])),
      Shapes::idx($shape, 'union_value') === null ? null : (TestUnion::__fromShape($shape['union_value'])),
      $shape['list_of_struct_foo']
        |> Vec\map(
          $$,
          $_val0 ==> $_val0
            |> Foo::__fromShape($$),
        ),
      $shape['map_of_string_to_struct_foo']
        |> Dict\map(
          $$,
          $_val1 ==> $_val1
            |> Foo::__fromShape($$),
        ),
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'foo_struct' => $this->foo_struct?->__toShape(),
      'union_value' => $this->union_value?->__toShape(),
      'list_of_struct_foo' => $this->list_of_struct_foo
        |> Vec\map(
          $$,
          ($_val0) ==> $_val0->__toShape(),
        ),
      'map_of_string_to_struct_foo' => $this->map_of_string_to_struct_foo
        |> Dict\map(
          $$,
          ($_val0) ==> $_val0->__toShape(),
        ),
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift exception:-
 * Baz
 */
class Baz extends \TException implements \IThriftSyncStruct, \IThriftExceptionMetadata {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'message',
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'some_field',
      'type' => \TType::STRUCT,
      'class' => Foo::class,
    ),
    3 => shape(
      'var' => 'some_container',
      'type' => \TType::SET,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'array',
    ),
    4 => shape(
      'var' => 'code',
      'type' => \TType::I32,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'message' => 1,
    'some_field' => 2,
    'some_container' => 3,
    'code' => 4,
  ];

  const type TConstructorShape = shape(
    ?'message' => ?string,
    ?'some_field' => ?Foo,
    ?'some_container' => ?dict<string, bool>,
    ?'code' => ?int,
  );

  const int STRUCTURAL_ID = 1663976252517274137;
  /**
   * Original thrift field:-
   * 1: string message
   */
  public string $message;
  /**
   * Original thrift field:-
   * 2: module.Foo some_field
   */
  public ?Foo $some_field;
  /**
   * Original thrift field:-
   * 3: set<string> some_container
   */
  public dict<string, bool> $some_container;
  /**
   * Original thrift field:-
   * 4: i32 code
   */
  public int $code;

  public function __construct(?string $message = null, ?Foo $some_field = null, ?dict<string, bool> $some_container = null, ?int $code = null)[] {
    parent::__construct();
    $this->message = $message ?? '';
    $this->some_field = $some_field;
    $this->some_container = $some_container ?? dict[];
    $this->code = $code ?? 0;
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'message'),
      Shapes::idx($shape, 'some_field'),
      Shapes::idx($shape, 'some_container'),
      Shapes::idx($shape, 'code'),
    );
  }

  public function getName()[]: string {
    return 'Baz';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getExceptionMetadata()[]: \tmeta_ThriftException {
    return tmeta_ThriftException::fromShape(
      shape(
        "name" => "module.Baz",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "message",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.Foo",
                    )
                  ),
                )
              ),
              "name" => "some_field",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "some_container",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "code",
            )
          ),
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}

/**
 * Original thrift exception:-
 * OptBaz
 */
class OptBaz extends \TException implements \IThriftSyncStruct, \IThriftExceptionMetadata {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'message',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'message' => 1,
  ];

  const type TConstructorShape = shape(
    ?'message' => ?string,
  );

  const int STRUCTURAL_ID = 546500496397478593;
  /**
   * Original thrift field:-
   * 1: string message
   */
  public string $message;

  public function __construct(?string $message = null)[] {
    parent::__construct();
    $this->message = $message ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'message'),
    );
  }

  public function getName()[]: string {
    return 'OptBaz';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getExceptionMetadata()[]: \tmeta_ThriftException {
    return tmeta_ThriftException::fromShape(
      shape(
        "name" => "module.OptBaz",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "message",
              "is_optional" => true,
            )
          ),
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

}