Skip to content

Deprecate fields and methods if file is deprecated#6613

Merged
johanbrandhorst merged 2 commits intogrpc-ecosystem:mainfrom
aidandj:aidan/file-deprecation-option
Apr 15, 2026
Merged

Deprecate fields and methods if file is deprecated#6613
johanbrandhorst merged 2 commits intogrpc-ecosystem:mainfrom
aidandj:aidan/file-deprecation-option

Conversation

@aidandj
Copy link
Copy Markdown
Contributor

@aidandj aidandj commented Apr 14, 2026

Being able to deprecate an entire file and mark methods and fields as deprecated is nice when deprecating an entire API. I started this MR by passing a file descriptor around to the methods in template, so I could check for file level deprecation, but because of how the files are merged, individual file options are lost before templating. So instead if a file is deprecated, I propagate that option to the fields and methods, which is technically less correct, but simplifies the logic a lot.

The prior art for this is the golang code generator deprecates all fields, methods, services, etc if a file is deprecated.

Signed-off-by: Aidan Jensen <aidan.jensen@robust.ai>
Copy link
Copy Markdown
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, thanks for this!

}

func deprecateFieldsAndMethods(file *descriptor.File) {
if opts := file.GetOptions(); opts != nil && opts.GetDeprecated() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we lift this check outside of this function so that it's clearer in the caller what's happening?


content := resp[0].GetContent()

var doc map[string]interface{}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use map[string]any

Signed-off-by: Aidan Jensen <aidan.jensen@robust.ai>
@aidandj aidandj requested a review from johanbrandhorst April 15, 2026 03:03
@aidandj
Copy link
Copy Markdown
Contributor Author

aidandj commented Apr 15, 2026

Some minor comments, thanks for this!

Good feedback, done!

Copy link
Copy Markdown
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@johanbrandhorst johanbrandhorst merged commit 42997a1 into grpc-ecosystem:main Apr 15, 2026
14 checks passed
@johanbrandhorst
Copy link
Copy Markdown
Collaborator

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants