Resolve CS0436 Warning caused by [BindableProperty] and [AttachedBindableProperty<T>]#3073
Merged
TheCodeTraveler merged 22 commits intomainfrom Feb 8, 2026
Merged
Conversation
…munityToolkit.Maui`
This reverts commit b68db09.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR resolves CS0436 type-conflict warnings by moving the [BindableProperty], [AttachedBindableProperty<T>], and AccessModifier types out of generator post-initialization output and into the CommunityToolkit.Maui assembly, and then reverting MediaElement/CameraView to manual bindable property declarations now that those features are scoped to CommunityToolkit.Maui.
Changes:
- Adds the bindable-property generator primitives (attributes, diagnostic ID holder, access-modifier enum) into
CommunityToolkit.Maui. - Removes generator post-initialization emission of those same primitives and updates source generator unit tests to reference the real types from
CommunityToolkit.Maui. - Reverts
MediaElementmedia sources andCameraViewaway from[BindableProperty]usage and removes the analyzer references from the corresponding projects.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Primitives/BindablePropertySourceGeneratorPrimatives/BindablePropertyDiagnostics.cs | Introduces a shared diagnostic ID holder used by the attributes’ [Experimental] marker. |
| src/CommunityToolkit.Maui/Primitives/BindablePropertySourceGeneratorPrimatives/BindablePropertyAttribute.shared.cs | Adds the shipped [BindableProperty] attribute definition to CommunityToolkit.Maui. |
| src/CommunityToolkit.Maui/Primitives/BindablePropertySourceGeneratorPrimatives/AttachedBindablePropertyAttribute.cs | Adds the shipped [AttachedBindableProperty<T>] attribute definition to CommunityToolkit.Maui. |
| src/CommunityToolkit.Maui/Primitives/BindablePropertySourceGeneratorPrimatives/AcessModifier.cs | Adds the shipped AccessModifier enum to CommunityToolkit.Maui. |
| src/CommunityToolkit.Maui.SourceGenerators/Generators/BindablePropertyAttributeSourceGenerator.cs | Stops emitting BindablePropertyAttribute via post-init; updates generator behavior for default binding mode emission. |
| src/CommunityToolkit.Maui.SourceGenerators/Generators/AttachedBindablePropertyAttributeSourceGenerator.cs | Stops emitting AttachedBindablePropertyAttribute and AccessModifier via post-init. |
| src/CommunityToolkit.Maui.SourceGenerators/BindablePropertyDiagnostic.cs | Removes the generator-side diagnostic ID holder now that it lives in CommunityToolkit.Maui. |
| src/CommunityToolkit.Maui.SourceGenerators.UnitTests/CommunityToolkit.Maui.SourceGenerators.UnitTests.csproj | Updates test project references to pull attribute/enum types from CommunityToolkit.Maui. |
| src/CommunityToolkit.Maui.SourceGenerators.UnitTests/BaseTest.cs | Updates Roslyn compilation references to include CommunityToolkit.Maui primitives. |
| src/CommunityToolkit.Maui.SourceGenerators.UnitTests/BindablePropertyAttributeSourceGeneratorTests/BaseBindablePropertyAttributeSourceGeneratorTest.cs | Removes expectations for post-init generated attribute source. |
| src/CommunityToolkit.Maui.SourceGenerators.UnitTests/AttachedBindablePropertyAttributeSourceGeneratorTests/BaseAttachedBindablePropertyAttributeGeneratorTest.cs | Removes expectations for post-init generated attribute/enum source. |
| src/CommunityToolkit.Maui.SourceGenerators.UnitTests/BindablePropertyAttributeSourceGeneratorTests/BindablePropertyAttributeSourceGenerator_IntegrationTests.cs | Updates expected generated output for default binding mode formatting. |
| src/CommunityToolkit.Maui.SourceGenerators.UnitTests/BindablePropertyAttributeSourceGeneratorTests/BindablePropertyAttributeSourceGenerator_EdgeCaseTests.cs | Updates expected generated output for default binding mode formatting. |
| src/CommunityToolkit.Maui.SourceGenerators.UnitTests/BindablePropertyAttributeSourceGeneratorTests/BindablePropertyAttributeSourceGenerator_CommonUsageTests.cs | Updates expected generated output for default binding mode formatting. |
| src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs | Reverts from [BindableProperty] to manual BindableProperty + wrapper property. |
| src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs | Reverts from [BindableProperty] to manual BindableProperty + wrapper property. |
| src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs | Reverts from [BindableProperty] to manual BindableProperty + wrapper property. |
| src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs | Reintroduces explicit bindable properties and wrappers for MediaElement. |
| src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj | Removes the source generator analyzer reference now that [BindableProperty] is no longer used here. |
| src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs | Reintroduces explicit bindable properties and wrappers for CameraView. |
| src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj | Removes the source generator analyzer reference now that [BindableProperty] is no longer used here. |
...tyToolkit.Maui/Primitives/BindablePropertySourceGeneratorPrimitives/AccessModifier.shared.cs
Show resolved
Hide resolved
...itives/BindablePropertySourceGeneratorPrimitives/AttachedBindablePropertyAttribute.shared.cs
Outdated
Show resolved
Hide resolved
...mitives/BindablePropertySourceGeneratorPrimitives/BindablePropertyAttribute.shared.shared.cs
Show resolved
Hide resolved
…https://github.com/CommunityToolkit/Maui into Resolve-CS0436-Caused-by-Bindable-Property-Attribute
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
...itives/BindablePropertySourceGeneratorPrimitives/AttachedBindablePropertyAttribute.shared.cs
Outdated
Show resolved
Hide resolved
...itives/BindablePropertySourceGeneratorPrimitives/AttachedBindablePropertyAttribute.shared.cs
Outdated
Show resolved
Hide resolved
…eratorPrimitives/AttachedBindablePropertyAttribute.shared.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…eratorPrimitives/AttachedBindablePropertyAttribute.shared.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
...itives/BindablePropertySourceGeneratorPrimitives/AttachedBindablePropertyAttribute.shared.cs
Outdated
Show resolved
Hide resolved
...mitives/BindablePropertySourceGeneratorPrimitives/BindablePropertyAttribute.shared.shared.cs
Show resolved
Hide resolved
VladislavAntonyuk
approved these changes
Feb 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
This PR moves the following classes into
CommunityToolkit.Maui:[BindableProperty][AttachedBindableProperty<T>]AccessModiferPreviously, the above classes were auto-generated by
BindablePropertySourceGeneratorandAttachedBindablePropertySourceGeneratorwhich enabled the above classes to be generated multiple times causing the CS0436 Warning:Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Now that
[BindableProperty]and[AttachedBindableProperty<T>]are specific toCommunityToolkit.Maui, they may no longer be used forCommunityToolkit.Maui.MediaElementandCommunityToolkit.Maui.Camera. This PR reverts the changes made in #2933 #2974 that implemented[BindableProperty].