You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mark OffscreenPageLimitProperty as obsolete and remove unused code (#31306)
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
## Description
This PR marks the `OffscreenPageLimitProperty` and all related methods
as obsolete throughout the .NET MAUI codebase to indicate that these
APIs are deprecated and should not be used in future development.
Additionally, it removes unused code that was identified during the
review process.
## Changes
### API Deprecation
Applied `[System.Obsolete]` attributes to the following APIs in
`Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific.TabbedPage`:
- `OffscreenPageLimitProperty` - The BindableProperty definition
- `GetOffscreenPageLimit(BindableObject)` - Static getter method
- `SetOffscreenPageLimit(BindableObject, int)` - Static setter method
- `OffscreenPageLimit(IPlatformElementConfiguration<Android,
FormsElement>)` - Extension method
- `SetOffscreenPageLimit(IPlatformElementConfiguration<Android,
FormsElement>, int)` - Extension setter method
### Implementation Updates
- Added `#pragma warning disable CS0618` around existing usage sites to
suppress obsolete warnings in internal implementation code:
- `TabbedPageRenderer.UpdateOffscreenPageLimit()` (Compatibility layer)
- **Removed unused code**: Deleted the `UpdateOffscreenPageLimit()`
method from `TabbedPageManager.cs` since no code was calling it
- Preserved the `UpdateOffscreenPageLimit()` method in
`TabbedPageRenderer.cs` (compatibility layer) where it is actually used
### Code Cleanup
The unused `UpdateOffscreenPageLimit()` method in the modern
`TabbedPageManager` implementation was removed as it was never called,
while preserving the same method in the compatibility layer where it's
properly utilized.
## Impact
- **Backward Compatibility**: All existing code continues to work
unchanged
- **Developer Guidance**: Developers using these APIs will now receive
compiler warnings indicating deprecation
- **Internal Implementation**: Framework internals continue to function
with appropriate warning suppression
- **Code Quality**: Removed dead code that was not being used
- **Future Direction**: Signals to developers that these APIs may be
removed in future versions
## Testing
- All existing TabbedPage unit tests continue to pass
- Core.Controls and Compatibility projects build successfully
- No breaking changes to public API surface beyond the addition of
obsolete attributes
This change follows the established pattern for deprecating APIs in the
.NET MAUI codebase and provides clear guidance to developers about the
future direction of these APIs.
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/dotnet/maui/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
0 commit comments