Skip to content

Commit fa5bab3

Browse files
sadroeckmeta-codesync[bot]
authored andcommitted
Add @thrift.Deprecated annotation definition
Summary: `thrift.Deprecated` is a structured annotation that can be applied to various Thrift definitions, to mark them as deprecated in their target language. This diff initially focusses on field access, to mark certain fields as "don't use anymore", in the migration period before they can be deleted. When applied, code generators can emit language-specific deprecation markers (e.g., `[[deprecated]]` in C++, `Deprecated` in Java) that produce compiler warnings when deprecated elements are used. The annotation includes an optional `message` field to explain why the element is deprecated and what to use instead, e.g: ```thrift struct User { thrift.Deprecated{message = "Use 'full_name' instead"} 1: string name; 2: string full_name; } ``` ## Devnote The fixture tests are empty, so each subsequent commit indicates what the changes are for each language. Reviewed By: praihan Differential Revision: D92099551 fbshipit-source-id: fcbdbe6fcd82c8551aa8edc25df8a8c489c9a6cb
1 parent 6c423b3 commit fa5bab3

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

thrift/annotation/thrift.thrift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,25 @@ struct AllowLegacyMissingUris {}
429429
@scope.Typedef
430430
@scope.FunctionParameter
431431
struct AllowUnsafeNonSealedKeyType {}
432+
433+
/**
434+
* Marks a definition as deprecated.
435+
*
436+
* When applied, generated code will include language-specific deprecation
437+
* markers that produce compiler warnings when the deprecated element is used.
438+
*
439+
* Example:
440+
* struct User {
441+
* @thrift.Deprecated{message = "Use 'full_name' instead"}
442+
* 1: string name;
443+
* 2: string full_name;
444+
* }
445+
*/
446+
@scope.Field
447+
struct Deprecated {
448+
/**
449+
* Explanation of why this is deprecated and what to use instead.
450+
* This message will appear in compiler warnings.
451+
*/
452+
1: string message;
453+
}

0 commit comments

Comments
 (0)