Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: dotnet/android#10510 (comment)

When a derived class has a property setter with ApiRemovedSince, but the base class only has a getter (no setter), clear the setter's ApiRemovedSince if the base getter is not removed. Also handle standalone setXxx methods that correspond to base class properties.

Fixes CA1416 warning for ListView.Adapter.set being incorrectly marked as unsupported on android15.0.

…e has getter-only

Context: dotnet/android#10510 (comment)

When a derived class has a property setter with `ApiRemovedSince`, but
the base class only has a getter (no setter), clear the setter's
`ApiRemovedSince` if the base getter is not removed. Also handle
standalone `setXxx` methods that correspond to base class properties.

Fixes `CA1416` warning for `ListView.Adapter.set` being incorrectly
marked as unsupported on `android15.0`.
jonathanpeppers added a commit to dotnet/android that referenced this pull request Dec 16, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes incorrect UnsupportedOSPlatform attribute generation for property setters when the base class only has a getter. The fix addresses CA1416 warnings by clearing ApiRemovedSince on derived class setters when the base property (accessed via its getter) is not marked as removed.

Key Changes:

  • Adds logic to handle property setters in derived classes when base class has getter-only properties
  • Adds handling for standalone setXxx methods that correspond to base class properties
  • Includes test coverage for the property setter scenario

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs Adds three conditional blocks to clear ApiRemovedSince on setters: one for class properties (lines 369-373), one for standalone setter methods (lines 380-393), and one for interface properties (lines 441-444)
tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs Adds test UnsupportedOSPlatformIgnoresPropertySetterOverridesWhenBaseHasGetterOnly to verify the fix for ListView.Adapter scenario

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.

1 participant