[generator] Better support deprecated property getter/setters. #1062
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #1033
When we are converting Java getter/setter pairs to C# properties, we can hit an interesting scenario where a getter may be
@Deprecatedand the setter is not, or vice versa:C# has traditionally not allowed
[Obsolete]to be placed on just agetor aset, it can only be placed on the entire property.This can lead to confusion because using the getter will report an obsolete warning when it is not obsolete. Thus, for properties, we only add
[Obsolete]in 2 cases:getis obsolete and there is nosetgetandsetare obsoleteWe have this comment in our code:
However, the compiler team has determined that preventing
[Obsolete]on property accessors was a bug, and has fixed it in C# 8: dotnet/roslyn#32571.Thus we can update
generatorto support scenarios in which only the Java getter or setter is marked as@Deprecated.