diff --git a/thrift/compiler/sema/patch_mutator.cc b/thrift/compiler/sema/patch_mutator.cc index dca305cf271..e923f448d9e 100644 --- a/thrift/compiler/sema/patch_mutator.cc +++ b/thrift/compiler/sema/patch_mutator.cc @@ -128,6 +128,20 @@ struct StructGen { operator t_struct&() { return generated; } operator t_type_ref() { return generated; } + void add_hack_name(std::string name) { + const t_type* annotation = dynamic_cast( + program_.scope()->find_by_uri(kHackNameUri)); + assert(annotation); + auto value = t_const_value::make_map(); + value->add_map( + std::make_unique("name"), + std::make_unique(std::move(name))); + value->set_ttype(*annotation); + auto hack_name = + std::make_unique(&program_, annotation, "", std::move(value)); + generated.add_structured_annotation(std::move(hack_name)); + } + void add_frozen_exclude() { const t_type* annotation = dynamic_cast( program_.scope()->find_by_uri(kCppFrozen2ExcludeUri)); @@ -453,6 +467,8 @@ t_struct& patch_generator::add_struct_patch( const t_const& annot, t_structured& value_type) { PatchGen gen{ {annot, gen_suffix_struct(annot, value_type, "Patch"), program_}}; + // Rename it for Hack to caution developers against accidental usage + gen.add_hack_name(value_type.name() + "PatchStructInternalDoNotUse"); gen.assign(value_type); gen.clear(); if (get_assign_only_annotation_or_null(value_type)) { diff --git a/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/module2_with_patch_types.php b/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/module2_with_patch_types.php index ebfe7356a83..844035a5f28 100644 --- a/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/module2_with_patch_types.php +++ b/thrift/compiler/test/fixtures/hack_service/out/hack_module2_with_patch/gen-hack/module2_with_patch_types.php @@ -131,7 +131,7 @@ public function getInstanceKey()[write_props]: string { * FBStructPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/hack/ns2/FBStructPatch'))>> -class FBStructPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class FBStructPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -266,7 +266,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'FBStructPatch'; + return 'FBStructPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -391,6 +391,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "FBStructPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::hack::ns2::FBStructPatchStruct>", diff --git a/thrift/compiler/test/fixtures/patch/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/patch/out/cpp2/gen-cpp2/module_metadata.cpp index 1a3be76b63e..0286e3cfa1c 100644 --- a/thrift/compiler/test/fixtures/patch/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/patch/out/cpp2/gen-cpp2/module_metadata.cpp @@ -278,6 +278,7 @@ StructMetadata<::test::fixtures::patch::MyDataPatchStruct>::gen(ThriftMetadata& field.structured_annotations() = f.structured_annotations; module_MyDataPatch.fields()->push_back(std::move(field)); } + module_MyDataPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("MyDataPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_MyDataPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataPatchStruct>") }, {"underlyingName", cvString("MyDataPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -374,6 +375,7 @@ StructMetadata<::test::fixtures::patch::MyDataWithCustomDefaultPatchStruct>::gen field.structured_annotations() = f.structured_annotations; module_MyDataWithCustomDefaultPatch.fields()->push_back(std::move(field)); } + module_MyDataWithCustomDefaultPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("MyDataWithCustomDefaultPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_MyDataWithCustomDefaultPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataWithCustomDefaultPatchStruct>") }, {"underlyingName", cvString("MyDataWithCustomDefaultPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -614,6 +616,7 @@ StructMetadata<::test::fixtures::patch::MyStructPatchStruct>::gen(ThriftMetadata field.structured_annotations() = f.structured_annotations; module_MyStructPatch.fields()->push_back(std::move(field)); } + module_MyStructPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("MyStructPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_MyStructPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyStructPatchStruct>") }, {"underlyingName", cvString("MyStructPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -902,6 +905,7 @@ StructMetadata<::test::fixtures::patch::LateDefStructPatchStruct>::gen(ThriftMet field.structured_annotations() = f.structured_annotations; module_LateDefStructPatch.fields()->push_back(std::move(field)); } + module_LateDefStructPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("LateDefStructPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_LateDefStructPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::LateDefStructPatchStruct>") }, {"underlyingName", cvString("LateDefStructPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -974,6 +978,7 @@ StructMetadata<::test::fixtures::patch::RecursivePatchStruct>::gen(ThriftMetadat field.structured_annotations() = f.structured_annotations; module_RecursivePatch.fields()->push_back(std::move(field)); } + module_RecursivePatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("RecursivePatchStructInternalDoNotUse") } }).cv_struct_ref()); module_RecursivePatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::RecursivePatchStruct>") }, {"underlyingName", cvString("RecursivePatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -1094,6 +1099,7 @@ StructMetadata<::test::fixtures::patch::BarPatchStruct>::gen(ThriftMetadata& met field.structured_annotations() = f.structured_annotations; module_BarPatch.fields()->push_back(std::move(field)); } + module_BarPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("BarPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_BarPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::BarPatchStruct>") }, {"underlyingName", cvString("BarPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -1190,6 +1196,7 @@ StructMetadata<::test::fixtures::patch::LoopPatchStruct>::gen(ThriftMetadata& me field.structured_annotations() = f.structured_annotations; module_LoopPatch.fields()->push_back(std::move(field)); } + module_LoopPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("LoopPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_LoopPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::AssignPatchAdapter<::test::fixtures::patch::LoopPatchStruct>") }, {"underlyingName", cvString("LoopPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -1238,6 +1245,7 @@ StructMetadata<::test::fixtures::patch::RefFieldsPatchStruct>::gen(ThriftMetadat field.structured_annotations() = f.structured_annotations; module_RefFieldsPatch.fields()->push_back(std::move(field)); } + module_RefFieldsPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("RefFieldsPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_RefFieldsPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::RefFieldsPatchStruct>") }, {"underlyingName", cvString("RefFieldsPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } diff --git a/thrift/compiler/test/fixtures/patch/out/hack/gen-hack/module_types.php b/thrift/compiler/test/fixtures/patch/out/hack/gen-hack/module_types.php index f4623de715c..8d5207afbab 100644 --- a/thrift/compiler/test/fixtures/patch/out/hack/gen-hack/module_types.php +++ b/thrift/compiler/test/fixtures/patch/out/hack/gen-hack/module_types.php @@ -3323,7 +3323,7 @@ public function readFromJson(string $jsonText): void { * MyDataPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/MyDataPatch'))>> -class MyDataPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class MyDataPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -3458,7 +3458,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'MyDataPatch'; + return 'MyDataPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -3583,6 +3583,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "MyDataPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataPatchStruct>", @@ -4169,7 +4174,7 @@ public function readFromJson(string $jsonText): void { * MyDataWithCustomDefaultPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/MyDataWithCustomDefaultPatch'))>> -class MyDataWithCustomDefaultPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class MyDataWithCustomDefaultPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -4304,7 +4309,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'MyDataWithCustomDefaultPatch'; + return 'MyDataWithCustomDefaultPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -4429,6 +4434,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "MyDataWithCustomDefaultPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataWithCustomDefaultPatchStruct>", @@ -6290,7 +6300,7 @@ public function readFromJson(string $jsonText): void { * MyStructPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/MyStructPatch'))>> -class MyStructPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class MyStructPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -6425,7 +6435,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'MyStructPatch'; + return 'MyStructPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -6550,6 +6560,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "MyStructPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyStructPatchStruct>", @@ -9463,7 +9478,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, 'var' => 'structWithCustomDefault', 'is_terse' => true, 'type' => \TType::STRUCT, - 'class' => \test\fixtures\patch\MyDataWithCustomDefaultPatch::class, + 'class' => \test\fixtures\patch\MyDataWithCustomDefaultPatchStructInternalDoNotUse::class, ), -31 => shape( 'var' => 'i32WithCustomDefault', @@ -9505,13 +9520,13 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, 'var' => 'optLateStructVal', 'is_terse' => true, 'type' => \TType::STRUCT, - 'class' => \test\fixtures\patch\LateDefStructPatch::class, + 'class' => \test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse::class, ), -24 => shape( 'var' => 'optStructVal', 'is_terse' => true, 'type' => \TType::STRUCT, - 'class' => \test\fixtures\patch\MyDataPatch::class, + 'class' => \test\fixtures\patch\MyDataPatchStructInternalDoNotUse::class, ), -23 => shape( 'var' => 'optEnumVal', @@ -9577,7 +9592,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, 'var' => 'lateStructVal', 'is_terse' => true, 'type' => \TType::STRUCT, - 'class' => \test\fixtures\patch\LateDefStructPatch::class, + 'class' => \test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse::class, ), -12 => shape( 'var' => 'unionVal', @@ -9589,7 +9604,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, 'var' => 'structVal', 'is_terse' => true, 'type' => \TType::STRUCT, - 'class' => \test\fixtures\patch\MyDataPatch::class, + 'class' => \test\fixtures\patch\MyDataPatchStructInternalDoNotUse::class, ), -10 => shape( 'var' => 'enumVal', @@ -9655,7 +9670,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, 'var' => 'structWithFieldCustomDefault', 'is_terse' => true, 'type' => \TType::STRUCT, - 'class' => \test\fixtures\patch\MyDataPatch::class, + 'class' => \test\fixtures\patch\MyDataPatchStructInternalDoNotUse::class, ), ]; const dict FIELDMAP = dict[ @@ -9695,15 +9710,15 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, ]; const type TConstructorShape = shape( - ?'structWithCustomDefault' => ?\test\fixtures\patch\MyDataWithCustomDefaultPatch, + ?'structWithCustomDefault' => ?\test\fixtures\patch\MyDataWithCustomDefaultPatchStructInternalDoNotUse, ?'i32WithCustomDefault' => ?\facebook\thrift\op\I32Patch, ?'mapMap' => ?\test\fixtures\patch\MyStructField30Patch, ?'listMap' => ?\test\fixtures\patch\MyStructField29Patch, ?'optMapVal' => ?\test\fixtures\patch\MyStructField28Patch, ?'optSetVal' => ?\test\fixtures\patch\MyStructField27Patch, ?'optListVal' => ?\test\fixtures\patch\MyStructField26Patch, - ?'optLateStructVal' => ?\test\fixtures\patch\LateDefStructPatch, - ?'optStructVal' => ?\test\fixtures\patch\MyDataPatch, + ?'optLateStructVal' => ?\test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse, + ?'optStructVal' => ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse, ?'optEnumVal' => ?\test\fixtures\patch\MyStructField23Patch, ?'optBinaryVal' => ?\facebook\thrift\op\BinaryPatch, ?'optStringVal' => ?\facebook\thrift\op\StringPatch, @@ -9714,9 +9729,9 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, ?'optI16Val' => ?\facebook\thrift\op\I16Patch, ?'optByteVal' => ?\facebook\thrift\op\BytePatch, ?'optBoolVal' => ?\facebook\thrift\op\BoolPatch, - ?'lateStructVal' => ?\test\fixtures\patch\LateDefStructPatch, + ?'lateStructVal' => ?\test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse, ?'unionVal' => ?\test\fixtures\patch\MyUnionPatch, - ?'structVal' => ?\test\fixtures\patch\MyDataPatch, + ?'structVal' => ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse, ?'enumVal' => ?\test\fixtures\patch\MyStructField10Patch, ?'binaryVal' => ?\facebook\thrift\op\BinaryPatch, ?'stringVal' => ?\facebook\thrift\op\StringPatch, @@ -9727,7 +9742,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, ?'i16Val' => ?\facebook\thrift\op\I16Patch, ?'byteVal' => ?\facebook\thrift\op\BytePatch, ?'boolVal' => ?\facebook\thrift\op\BoolPatch, - ?'structWithFieldCustomDefault' => ?\test\fixtures\patch\MyDataPatch, + ?'structWithFieldCustomDefault' => ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse, ); const int STRUCTURAL_ID = 2177152892435994657; @@ -9735,7 +9750,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, * Original thrift field:- * -32: module.MyDataWithCustomDefaultPatch structWithCustomDefault */ - public ?\test\fixtures\patch\MyDataWithCustomDefaultPatch $structWithCustomDefault; + public ?\test\fixtures\patch\MyDataWithCustomDefaultPatchStructInternalDoNotUse $structWithCustomDefault; /** * Original thrift field:- * -31: patch.I32Patch i32WithCustomDefault @@ -9770,12 +9785,12 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, * Original thrift field:- * -25: module.LateDefStructPatch optLateStructVal */ - public ?\test\fixtures\patch\LateDefStructPatch $optLateStructVal; + public ?\test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse $optLateStructVal; /** * Original thrift field:- * -24: module.MyDataPatch optStructVal */ - public ?\test\fixtures\patch\MyDataPatch $optStructVal; + public ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse $optStructVal; /** * Original thrift field:- * -23: module.MyStructField23Patch optEnumVal @@ -9830,7 +9845,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, * Original thrift field:- * -13: module.LateDefStructPatch lateStructVal */ - public ?\test\fixtures\patch\LateDefStructPatch $lateStructVal; + public ?\test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse $lateStructVal; /** * Original thrift field:- * -12: module.MyUnionPatch unionVal @@ -9840,7 +9855,7 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, * Original thrift field:- * -11: module.MyDataPatch structVal */ - public ?\test\fixtures\patch\MyDataPatch $structVal; + public ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse $structVal; /** * Original thrift field:- * -10: module.MyStructField10Patch enumVal @@ -9895,9 +9910,9 @@ class MyStructFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, * Original thrift field:- * 1: module.MyDataPatch structWithFieldCustomDefault */ - public ?\test\fixtures\patch\MyDataPatch $structWithFieldCustomDefault; + public ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse $structWithFieldCustomDefault; - public function __construct(?\test\fixtures\patch\MyDataWithCustomDefaultPatch $structWithCustomDefault = null, ?\facebook\thrift\op\I32Patch $i32WithCustomDefault = null, ?\test\fixtures\patch\MyStructField30Patch $mapMap = null, ?\test\fixtures\patch\MyStructField29Patch $listMap = null, ?\test\fixtures\patch\MyStructField28Patch $optMapVal = null, ?\test\fixtures\patch\MyStructField27Patch $optSetVal = null, ?\test\fixtures\patch\MyStructField26Patch $optListVal = null, ?\test\fixtures\patch\LateDefStructPatch $optLateStructVal = null, ?\test\fixtures\patch\MyDataPatch $optStructVal = null, ?\test\fixtures\patch\MyStructField23Patch $optEnumVal = null, ?\facebook\thrift\op\BinaryPatch $optBinaryVal = null, ?\facebook\thrift\op\StringPatch $optStringVal = null, ?\facebook\thrift\op\DoublePatch $optDoubleVal = null, ?\facebook\thrift\op\FloatPatch $optFloatVal = null, ?\facebook\thrift\op\I64Patch $optI64Val = null, ?\facebook\thrift\op\I32Patch $optI32Val = null, ?\facebook\thrift\op\I16Patch $optI16Val = null, ?\facebook\thrift\op\BytePatch $optByteVal = null, ?\facebook\thrift\op\BoolPatch $optBoolVal = null, ?\test\fixtures\patch\LateDefStructPatch $lateStructVal = null, ?\test\fixtures\patch\MyUnionPatch $unionVal = null, ?\test\fixtures\patch\MyDataPatch $structVal = null, ?\test\fixtures\patch\MyStructField10Patch $enumVal = null, ?\facebook\thrift\op\BinaryPatch $binaryVal = null, ?\facebook\thrift\op\StringPatch $stringVal = null, ?\facebook\thrift\op\DoublePatch $doubleVal = null, ?\facebook\thrift\op\FloatPatch $floatVal = null, ?\facebook\thrift\op\I64Patch $i64Val = null, ?\facebook\thrift\op\I32Patch $i32Val = null, ?\facebook\thrift\op\I16Patch $i16Val = null, ?\facebook\thrift\op\BytePatch $byteVal = null, ?\facebook\thrift\op\BoolPatch $boolVal = null, ?\test\fixtures\patch\MyDataPatch $structWithFieldCustomDefault = null)[] { + public function __construct(?\test\fixtures\patch\MyDataWithCustomDefaultPatchStructInternalDoNotUse $structWithCustomDefault = null, ?\facebook\thrift\op\I32Patch $i32WithCustomDefault = null, ?\test\fixtures\patch\MyStructField30Patch $mapMap = null, ?\test\fixtures\patch\MyStructField29Patch $listMap = null, ?\test\fixtures\patch\MyStructField28Patch $optMapVal = null, ?\test\fixtures\patch\MyStructField27Patch $optSetVal = null, ?\test\fixtures\patch\MyStructField26Patch $optListVal = null, ?\test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse $optLateStructVal = null, ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse $optStructVal = null, ?\test\fixtures\patch\MyStructField23Patch $optEnumVal = null, ?\facebook\thrift\op\BinaryPatch $optBinaryVal = null, ?\facebook\thrift\op\StringPatch $optStringVal = null, ?\facebook\thrift\op\DoublePatch $optDoubleVal = null, ?\facebook\thrift\op\FloatPatch $optFloatVal = null, ?\facebook\thrift\op\I64Patch $optI64Val = null, ?\facebook\thrift\op\I32Patch $optI32Val = null, ?\facebook\thrift\op\I16Patch $optI16Val = null, ?\facebook\thrift\op\BytePatch $optByteVal = null, ?\facebook\thrift\op\BoolPatch $optBoolVal = null, ?\test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse $lateStructVal = null, ?\test\fixtures\patch\MyUnionPatch $unionVal = null, ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse $structVal = null, ?\test\fixtures\patch\MyStructField10Patch $enumVal = null, ?\facebook\thrift\op\BinaryPatch $binaryVal = null, ?\facebook\thrift\op\StringPatch $stringVal = null, ?\facebook\thrift\op\DoublePatch $doubleVal = null, ?\facebook\thrift\op\FloatPatch $floatVal = null, ?\facebook\thrift\op\I64Patch $i64Val = null, ?\facebook\thrift\op\I32Patch $i32Val = null, ?\facebook\thrift\op\I16Patch $i16Val = null, ?\facebook\thrift\op\BytePatch $byteVal = null, ?\facebook\thrift\op\BoolPatch $boolVal = null, ?\test\fixtures\patch\MyDataPatchStructInternalDoNotUse $structWithFieldCustomDefault = null)[] { $this->structWithCustomDefault = $structWithCustomDefault; $this->i32WithCustomDefault = $i32WithCustomDefault; $this->mapMap = $mapMap; @@ -10541,6 +10556,11 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot ), ], 'type' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "MyDataWithCustomDefaultPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataWithCustomDefaultPatchStruct>", @@ -10659,6 +10679,11 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot ), ], 'type' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "LateDefStructPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::LateDefStructPatchStruct>", @@ -10676,6 +10701,11 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot ), ], 'type' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "MyDataPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataPatchStruct>", @@ -10854,6 +10884,11 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot ), ], 'type' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "LateDefStructPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::LateDefStructPatchStruct>", @@ -10888,6 +10923,11 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot ), ], 'type' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "MyDataPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataPatchStruct>", @@ -11066,6 +11106,11 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot ), ], 'type' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "MyDataPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataPatchStruct>", @@ -11091,8 +11136,8 @@ public function readFromJson(string $jsonText): void { } if (idx($parsed, 'structWithCustomDefault') !== null) { - $_tmp0 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['structWithCustomDefault'])); - $_tmp1 = \test\fixtures\patch\MyDataWithCustomDefaultPatch::withDefaultValues(); + $_tmp0 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['structWithCustomDefault'])); + $_tmp1 = \test\fixtures\patch\MyDataWithCustomDefaultPatchStructInternalDoNotUse::withDefaultValues(); $_tmp1->readFromJson($_tmp0); $this->structWithCustomDefault = $_tmp1; } @@ -11133,14 +11178,14 @@ public function readFromJson(string $jsonText): void { $this->optListVal = $_tmp13; } if (idx($parsed, 'optLateStructVal') !== null) { - $_tmp14 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['optLateStructVal'])); - $_tmp15 = \test\fixtures\patch\LateDefStructPatch::withDefaultValues(); + $_tmp14 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['optLateStructVal'])); + $_tmp15 = \test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse::withDefaultValues(); $_tmp15->readFromJson($_tmp14); $this->optLateStructVal = $_tmp15; } if (idx($parsed, 'optStructVal') !== null) { - $_tmp16 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['optStructVal'])); - $_tmp17 = \test\fixtures\patch\MyDataPatch::withDefaultValues(); + $_tmp16 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['optStructVal'])); + $_tmp17 = \test\fixtures\patch\MyDataPatchStructInternalDoNotUse::withDefaultValues(); $_tmp17->readFromJson($_tmp16); $this->optStructVal = $_tmp17; } @@ -11205,8 +11250,8 @@ public function readFromJson(string $jsonText): void { $this->optBoolVal = $_tmp37; } if (idx($parsed, 'lateStructVal') !== null) { - $_tmp38 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['lateStructVal'])); - $_tmp39 = \test\fixtures\patch\LateDefStructPatch::withDefaultValues(); + $_tmp38 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['lateStructVal'])); + $_tmp39 = \test\fixtures\patch\LateDefStructPatchStructInternalDoNotUse::withDefaultValues(); $_tmp39->readFromJson($_tmp38); $this->lateStructVal = $_tmp39; } @@ -11217,8 +11262,8 @@ public function readFromJson(string $jsonText): void { $this->unionVal = $_tmp41; } if (idx($parsed, 'structVal') !== null) { - $_tmp42 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['structVal'])); - $_tmp43 = \test\fixtures\patch\MyDataPatch::withDefaultValues(); + $_tmp42 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['structVal'])); + $_tmp43 = \test\fixtures\patch\MyDataPatchStructInternalDoNotUse::withDefaultValues(); $_tmp43->readFromJson($_tmp42); $this->structVal = $_tmp43; } @@ -11283,8 +11328,8 @@ public function readFromJson(string $jsonText): void { $this->boolVal = $_tmp63; } if (idx($parsed, 'structWithFieldCustomDefault') !== null) { - $_tmp64 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['structWithFieldCustomDefault'])); - $_tmp65 = \test\fixtures\patch\MyDataPatch::withDefaultValues(); + $_tmp64 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['structWithFieldCustomDefault'])); + $_tmp65 = \test\fixtures\patch\MyDataPatchStructInternalDoNotUse::withDefaultValues(); $_tmp65->readFromJson($_tmp64); $this->structWithFieldCustomDefault = $_tmp65; } @@ -12791,7 +12836,7 @@ public function readFromJson(string $jsonText): void { * LateDefStructPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/LateDefStructPatch'))>> -class LateDefStructPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class LateDefStructPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -12926,7 +12971,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'LateDefStructPatch'; + return 'LateDefStructPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -13051,6 +13096,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "LateDefStructPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::LateDefStructPatchStruct>", @@ -13463,7 +13513,7 @@ public function readFromJson(string $jsonText): void { * RecursivePatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/RecursivePatch'))>> -class RecursivePatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class RecursivePatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -13598,7 +13648,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'RecursivePatch'; + return 'RecursivePatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -13723,6 +13773,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "RecursivePatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::RecursivePatchStruct>", @@ -14443,7 +14498,7 @@ public function readFromJson(string $jsonText): void { * BarPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/BarPatch'))>> -class BarPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class BarPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -14578,7 +14633,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'BarPatch'; + return 'BarPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -14703,6 +14758,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "BarPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::BarPatchStruct>", @@ -14838,7 +14898,7 @@ class BarFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThr 'var' => 'loop', 'is_terse' => true, 'type' => \TType::STRUCT, - 'class' => \test\fixtures\patch\LoopPatch::class, + 'class' => \test\fixtures\patch\LoopPatchStructInternalDoNotUse::class, ), ]; const dict FIELDMAP = dict[ @@ -14846,7 +14906,7 @@ class BarFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThr ]; const type TConstructorShape = shape( - ?'loop' => ?\test\fixtures\patch\LoopPatch, + ?'loop' => ?\test\fixtures\patch\LoopPatchStructInternalDoNotUse, ); const int STRUCTURAL_ID = 3282171960754554582; @@ -14854,9 +14914,9 @@ class BarFieldPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThr * Original thrift field:- * -1: module.LoopPatch loop */ - public ?\test\fixtures\patch\LoopPatch $loop; + public ?\test\fixtures\patch\LoopPatchStructInternalDoNotUse $loop; - public function __construct(?\test\fixtures\patch\LoopPatch $loop = null)[] { + public function __construct(?\test\fixtures\patch\LoopPatchStructInternalDoNotUse $loop = null)[] { $this->loop = $loop; } @@ -14924,6 +14984,11 @@ public static function getAllStructuredAnnotations()[write_props]: \TStructAnnot ), ], 'type' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "LoopPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::AssignPatchAdapter<::test::fixtures::patch::LoopPatchStruct>", @@ -14949,8 +15014,8 @@ public function readFromJson(string $jsonText): void { } if (idx($parsed, 'loop') !== null) { - $_tmp0 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['loop'])); - $_tmp1 = \test\fixtures\patch\LoopPatch::withDefaultValues(); + $_tmp0 = \json_encode(HH\FIXME\UNSAFE_CAST($parsed['loop'])); + $_tmp1 = \test\fixtures\patch\LoopPatchStructInternalDoNotUse::withDefaultValues(); $_tmp1->readFromJson($_tmp0); $this->loop = $_tmp1; } @@ -15226,7 +15291,7 @@ public function readFromJson(string $jsonText): void { * LoopPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/LoopPatch'))>> -class LoopPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class LoopPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -15289,7 +15354,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'LoopPatch'; + return 'LoopPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -15337,6 +15402,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "LoopPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::AssignPatchAdapter<::test::fixtures::patch::LoopPatchStruct>", @@ -15533,7 +15603,7 @@ public function readFromJson(string $jsonText): void { * RefFieldsPatch */ <<\ThriftTypeInfo(shape('uri' => 'test.dev/fixtures/patch/RefFieldsPatch'))>> -class RefFieldsPatch implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { +class RefFieldsPatchStructInternalDoNotUse implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftStructWithClearTerseFields { use \ThriftSerializationTrait; const \ThriftStructTypes::TSpec SPEC = dict[ @@ -15668,7 +15738,7 @@ public static function fromShape(self::TConstructorShape $shape)[]: this { } public function getName()[]: string { - return 'RefFieldsPatch'; + return 'RefFieldsPatchStructInternalDoNotUse'; } public function clearTerseFields()[write_props]: void { @@ -15793,6 +15863,11 @@ public static function getStructMetadata()[]: \tmeta_ThriftStruct { public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations { return shape( 'struct' => dict[ + '\facebook\thrift\annotation\hack\Name' => \facebook\thrift\annotation\hack\Name::fromShape( + shape( + "name" => "RefFieldsPatchStructInternalDoNotUse", + ) + ), '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape( shape( "name" => "::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::RefFieldsPatchStruct>", diff --git a/thrift/compiler/test/fixtures/patch/out/json_experimental/gen-json_experimental/module.json b/thrift/compiler/test/fixtures/patch/out/json_experimental/gen-json_experimental/module.json index b451a58e1f6..63205acb0a3 100644 --- a/thrift/compiler/test/fixtures/patch/out/json_experimental/gen-json_experimental/module.json +++ b/thrift/compiler/test/fixtures/patch/out/json_experimental/gen-json_experimental/module.json @@ -680,6 +680,14 @@ "MyDataPatch" : { "name" : "MyDataPatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "MyDataPatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", @@ -889,6 +897,14 @@ "MyDataWithCustomDefaultPatch" : { "name" : "MyDataWithCustomDefaultPatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "MyDataWithCustomDefaultPatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", @@ -1453,6 +1469,14 @@ "MyStructPatch" : { "name" : "MyStructPatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "MyStructPatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", @@ -3204,6 +3228,14 @@ "LateDefStructPatch" : { "name" : "LateDefStructPatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "LateDefStructPatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", @@ -3353,6 +3385,14 @@ "RecursivePatch" : { "name" : "RecursivePatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "RecursivePatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", @@ -3580,6 +3620,14 @@ "BarPatch" : { "name" : "BarPatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "BarPatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", @@ -3774,6 +3822,14 @@ "LoopPatch" : { "name" : "LoopPatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "LoopPatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", @@ -3851,6 +3907,14 @@ "RefFieldsPatch" : { "name" : "RefFieldsPatch", "structured_annotations": { + "hack.Name" : { + "type" : { + "type" : "struct", + "name" : "Name", + "path" : "thrift/annotation/hack.thrift" +}, + "value" : {"name": "RefFieldsPatchStructInternalDoNotUse"} + }, "cpp.Adapter" : { "type" : { "type" : "struct", diff --git a/thrift/compiler/test/fixtures/patch/out/python/gen-python/test/fixtures/patch/module/thrift_metadata.py b/thrift/compiler/test/fixtures/patch/out/python/gen-python/test/fixtures/patch/module/thrift_metadata.py index 6e3868dca15..0f5f20d21d5 100644 --- a/thrift/compiler/test/fixtures/patch/out/python/gen-python/test/fixtures/patch/module/thrift_metadata.py +++ b/thrift/compiler/test/fixtures/patch/out/python/gen-python/test/fixtures/patch/module/thrift_metadata.py @@ -421,6 +421,7 @@ def _fbthrift_gen_metadata_struct_MyDataPatch(metadata_struct: _fbthrift_metadat struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="MyDataPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="MyDataPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -548,6 +549,7 @@ def _fbthrift_gen_metadata_struct_MyDataWithCustomDefaultPatch(metadata_struct: struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="MyDataWithCustomDefaultPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyDataWithCustomDefaultPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="MyDataWithCustomDefaultPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -869,6 +871,7 @@ def _fbthrift_gen_metadata_struct_MyStructPatch(metadata_struct: _fbthrift_metad struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="MyStructPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::MyStructPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="MyStructPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -1532,6 +1535,7 @@ def _fbthrift_gen_metadata_struct_LateDefStructPatch(metadata_struct: _fbthrift_ struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="LateDefStructPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::LateDefStructPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="LateDefStructPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -1645,6 +1649,7 @@ def _fbthrift_gen_metadata_struct_RecursivePatch(metadata_struct: _fbthrift_meta struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="RecursivePatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::RecursivePatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="RecursivePatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -1795,6 +1800,7 @@ def _fbthrift_gen_metadata_struct_BarPatch(metadata_struct: _fbthrift_metadata.T struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="BarPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::BarPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="BarPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -1908,6 +1914,7 @@ def _fbthrift_gen_metadata_struct_LoopPatch(metadata_struct: _fbthrift_metadata. struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="LoopPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::AssignPatchAdapter<::test::fixtures::patch::LoopPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="LoopPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -1973,6 +1980,7 @@ def _fbthrift_gen_metadata_struct_RefFieldsPatch(metadata_struct: _fbthrift_meta struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="RefFieldsPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::patch::RefFieldsPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="RefFieldsPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) diff --git a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp index 064a2f9cdbe..fd7f274d6c0 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp +++ b/thrift/compiler/test/fixtures/python_capi/out/cpp2/gen-cpp2/module_metadata.cpp @@ -354,6 +354,7 @@ StructMetadata<::test::fixtures::python_capi::MyStructPatchStruct>::gen(ThriftMe field.structured_annotations() = f.structured_annotations; module_MyStructPatch.fields()->push_back(std::move(field)); } + module_MyStructPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("MyStructPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_MyStructPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::python_capi::MyStructPatchStruct>") }, {"underlyingName", cvString("MyStructPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } @@ -546,6 +547,7 @@ StructMetadata<::test::fixtures::python_capi::MyDataItemPatchStruct>::gen(Thrift field.structured_annotations() = f.structured_annotations; module_MyDataItemPatch.fields()->push_back(std::move(field)); } + module_MyDataItemPatch.structured_annotations()->push_back(*cvStruct("hack.Name", { {"name", cvString("MyDataItemPatchStructInternalDoNotUse") } }).cv_struct_ref()); module_MyDataItemPatch.structured_annotations()->push_back(*cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::python_capi::MyDataItemPatchStruct>") }, {"underlyingName", cvString("MyDataItemPatchStruct") }, {"extraNamespace", cvString("") } }).cv_struct_ref()); return res.first->second; } diff --git a/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py b/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py index c59ac177b94..0f42e8d4d9b 100644 --- a/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py +++ b/thrift/compiler/test/fixtures/python_capi/out/python/gen-python/test/fixtures/python_capi/module/thrift_metadata.py @@ -589,6 +589,7 @@ def _fbthrift_gen_metadata_struct_MyStructPatch(metadata_struct: _fbthrift_metad struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="MyStructPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::python_capi::MyStructPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="MyStructPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict) @@ -904,6 +905,7 @@ def _fbthrift_gen_metadata_struct_MyDataItemPatch(metadata_struct: _fbthrift_met struct_dict[qualified_name] = _fbthrift_metadata.ThriftStruct(name=qualified_name, fields=fields, is_union=False, structured_annotations=[ + _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="hack.Name"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="MyDataItemPatchStructInternalDoNotUse"), }), _fbthrift_metadata.ThriftConstStruct(type=_fbthrift_metadata.ThriftStructType(name="cpp.Adapter"), fields= { "name": _fbthrift_metadata.ThriftConstValue(cv_string="::apache::thrift::op::detail::StructPatchAdapter<::test::fixtures::python_capi::MyDataItemPatchStruct>"), "underlyingName": _fbthrift_metadata.ThriftConstValue(cv_string="MyDataItemPatchStruct"), "extraNamespace": _fbthrift_metadata.ThriftConstValue(cv_string=""), }), ]) new_struct = metadata_struct(structs=struct_dict)