Skip to content

Attribute deprecated_readonly #8192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Zguy
Copy link

@Zguy Zguy commented Dec 20, 2023

Adds support for a deprecated_readonly attribute.

While deprecated removes the field entirely from generated code, both getters and setters, deprecated_readonly only removes the setters and keeps the getters.

It's useful for backwards compatibility in some cases. A program might read a buffer written before the deprecation, read the deprecated field if it has a value, do some applicable conversion, and write to a non-deprecated field.

Fixes #7940

Some things to look out for

  • I have not fully tested the code generation of all languages. I have tested C++ and C#, the rest I've only visually inspected the generated code of. There might be edge cases I've missed, especially in languages I'm not familiar with.
  • I took the liberty of adding the deprecated_readonly attribute to the color field in the monster.fbs sample. Let me know if I should revert this.
  • I added deprecated_readonly to the middle of reflection.fbs next to deprecated. I'm not sure if this file needs to keep backwards conformity. If it does, let me know, and I'll move it to the end.
  • I wanted to have the C# json serializer support honor the deprecated_readonly attribute. There was no easy way to do this and the solution I came up with I find a bit invasive. I put it in a separate commit for easy removal, if it comes to that.

Copy link

google-cla bot commented Dec 20, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Zguy
Copy link
Author

Zguy commented Mar 26, 2024

@dbaileychess Not sure what the proper etiquette is here, so apologies if tagging you like this is out of line, but I'd love to get this PR reviewed.

Copy link
Contributor

This pull request is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Sep 24, 2024
@Zguy
Copy link
Author

Zguy commented Sep 26, 2024

I'm still hoping to get this merged. Not stale.

@github-actions github-actions bot removed the stale label Sep 26, 2024
@Zguy Zguy force-pushed the deprecated_readonly branch from 87d61ba to 5c41cec Compare February 18, 2025 21:54
Zguy added 2 commits May 18, 2025 13:15
While `deprecated` removes the field entirely from generated code, both getters and setters, `deprecated_readonly` only removes the setters and keeps the getters.

It's useful for backwards compatibility in some cases. A program might read a buffer written before the deprecation, read the deprecated field if it has a value, do some applicable conversion, and write to a non-deprecated field.

Fixes google#7940
@Zguy Zguy force-pushed the deprecated_readonly branch from 5c41cec to 18a8003 Compare May 18, 2025 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecated-but-readable table fields?
1 participant