Restrict AddPopup extensions to View to avoid ContentPage from being allowed#2715
Restrict AddPopup extensions to View to avoid ContentPage from being allowed#2715
Conversation
There was a problem hiding this comment.
Pull Request Overview
The PR tightens the generic constraints on AddPopup extension methods to only allow View types (preventing ContentPage usage) and updates related XML docs.
- Changed all
TPopupViewconstraints fromIViewtoView - Updated
<typeparam>XML comments to referenceViewinstead ofIView - Ensured
AddPopupoverloads correctly restrict input types
Comments suppressed due to low confidence (3)
src/CommunityToolkit.Maui/Extensions/ServiceCollectionExtensions.shared.cs:38
- The XML doc indicates
TPopupViewModelis constrained toINotifyPropertyChanged, but the code useswhere TPopupViewModel : notnull. Update the constraint or the doc to match.
/// <typeparam name="TPopupViewModel">The type of the ViewModel to add. Constrained to
src/CommunityToolkit.Maui/Extensions/ServiceCollectionExtensions.shared.cs:52
- This overload is
AddSingletonPopup, but the doc still saysServiceLifetime.Transient. It should referenceServiceLifetime.Singleton.
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
src/CommunityToolkit.Maui/Extensions/ServiceCollectionExtensions.shared.cs:68
- The documentation for the
AddSingletonPopup<TPopupView, TPopupViewModel>overload still mentionsTransientlifetime; this should be updated toSingleton.
/// <see cref="IServiceCollection"/> with <see cref="ServiceLifetime.Transient"/> lifetime.
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Thanks Shaun! I've added the breaking-change label since this technically modifies our API surface.
Let's discuss internally if it merits another major version. It may not impact many (if any) developers.
Yeah that's fair. Although it is breaking the rules we're too lax and if a dev provided something like ContentPage it broke. I guess there was the possibility of a dev creating their own IView implementation but I suspect that chance is very low |
…allowed
Description of Change
Restricts the types allowed into
AddXPopupextension methods to preventContentPagefrom being passed in.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information