[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
@Deprecated
and the setter is not, or vice versa:C# has traditionally not allowed
[Obsolete]
to be placed on just aget
or 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:get
is obsolete and there is noset
get
andset
are 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
generator
to support scenarios in which only the Java getter or setter is marked as@Deprecated
.