Use [BindableProperty] for RatingView#2964
Use [BindableProperty] for RatingView#2964TheCodeTraveler merged 10 commits intoCommunityToolkit:mainfrom
[BindableProperty] for RatingView#2964Conversation
…dable properties, fixed failing tests and had to remove 2 as these no longer made sense. There was a hard coded Default which was added to the Defaults as well. Only issue is that the DefaultValue use from the SG only returns an Int no matter what the default Value should be like a Bool, Double, Color etc so there are CreateDefault Methods to resolve this until the SG is fixed and these can be removed...
There was a problem hiding this comment.
Pull request overview
This PR converts the RatingView control from using longhand BindableProperty declarations to the internal source-generated [BindableProperty] attribute approach, making the code more concise and maintainable. The changes also add XML documentation comments to all properties and modify the RatingViewDefaults class to use fields instead of properties.
Key changes:
- Replaced 10 manually defined
BindablePropertydeclarations with source-generated[BindableProperty]attributes - Added comprehensive XML documentation to all public properties
- Introduced default value creator methods and coercion methods to work around source generator limitations
- Removed two unit tests that directly tested
BindableProperty.ValidateValuemethods
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs | Converted from longhand BindableProperty to source-generated attributes; added XML docs; implemented default value creators and coercion methods |
| src/CommunityToolkit.Maui.UnitTests/Views/RatingView/RatingViewTests.cs | Removed two validator tests that are no longer applicable with source-generated properties |
| src/CommunityToolkit.Maui.Core/Primitives/Defaults/RatingViewDefaults.shared.cs | Changed properties to fields (readonly/const) and added new constant for RatingViewFillOption |
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs
Outdated
Show resolved
Hide resolved
[BindableProperty] for RatingView
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Thanks @CliffAgius!
I updated this PR from the main branch to bring in the improvements I added to BindablePropertySourceGenerator, like support for Default Values like enum, double, etc. and updated the Bindable Property Attributes accordingly.
I also moved the ArgumentOutOfRange validation to PropertyChanging to ensure the property doesn't get set to an invalid value; PropertyChanged only fires after the Bindable Property's value has been updated.
I also removed the Validators from Rating and MaximumRating because they block PropertyChanging and PropertyChanged from running if the validation is false; MAUI runs the Validators first, then updates the value of the Bindable Property.
And I also added [Obsolete] to FillWhenTapped . CoPilot helped point out that we don't use FillWhenTapped anywhere in the RatingView source code, and it isn't documented anywhere in our docs. It must've been a vestige from when we first created RatingView that we forgot to remove. We'll remove it in the .NET 11 PR.
Description of Change
Converted the RatingView from using longhand Binding to using the Internal BindableProperty Source Generated version to make the code look and read cleaner.
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information