Skip to content

Use [BindableProperty] for RatingView#2964

Merged
TheCodeTraveler merged 10 commits intoCommunityToolkit:mainfrom
CliffAgius:UpdateRatingView
Nov 24, 2025
Merged

Use [BindableProperty] for RatingView#2964
TheCodeTraveler merged 10 commits intoCommunityToolkit:mainfrom
CliffAgius:UpdateRatingView

Conversation

@CliffAgius
Copy link
Contributor

@CliffAgius CliffAgius commented Nov 24, 2025

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

Additional information

…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...
Copilot AI review requested due to automatic review settings November 24, 2025 14:55
@CliffAgius CliffAgius self-assigned this Nov 24, 2025
Copy link
Contributor

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 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 BindableProperty declarations 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.ValidateValue methods

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

@TheCodeTraveler TheCodeTraveler changed the title Update rating view Use [BindableProperty] for RatingView Nov 24, 2025
Copilot AI review requested due to automatic review settings November 24, 2025 19:36
Copy link
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings November 24, 2025 19:50
Copy link
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings November 24, 2025 20:13
Copy link
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

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

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.

@TheCodeTraveler TheCodeTraveler merged commit d9a5085 into CommunityToolkit:main Nov 24, 2025
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants