Skip to content

Resolve CS0436 Warning caused by [BindableProperty] and [AttachedBindableProperty<T>]#3073

Merged
TheCodeTraveler merged 22 commits intomainfrom
Resolve-CS0436-Caused-by-Bindable-Property-Attribute
Feb 8, 2026
Merged

Resolve CS0436 Warning caused by [BindableProperty] and [AttachedBindableProperty<T>]#3073
TheCodeTraveler merged 22 commits intomainfrom
Resolve-CS0436-Caused-by-Bindable-Property-Attribute

Conversation

@TheCodeTraveler
Copy link
Copy Markdown
Collaborator

@TheCodeTraveler TheCodeTraveler commented Feb 7, 2026

Description of Change

This PR moves the following classes into CommunityToolkit.Maui:

  • [BindableProperty]
  • [AttachedBindableProperty<T>]
  • AccessModifer

Previously, the above classes were auto-generated by BindablePropertySourceGenerator and AttachedBindablePropertySourceGenerator which enabled the above classes to be generated multiple times causing the CS0436 Warning:

The type 'CommunityToolkit.Maui.BindablePropertyAttribute' in 'assembly' conflicts with the imported type 'CommunityToolkit.Maui.BindablePropertyAttribute' in 'assembly'. Using the type defined in 'assembly'.

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard

Additional information

Now that [BindableProperty] and [AttachedBindableProperty<T>] are specific to CommunityToolkit.Maui, they may no longer be used for CommunityToolkit.Maui.MediaElement and CommunityToolkit.Maui.Camera. This PR reverts the changes made in #2933 #2974 that implemented [BindableProperty].

Copy link
Copy Markdown
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 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 MediaElement media sources and CameraView away 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.

Copy link
Copy Markdown
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

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

…eratorPrimitives/AttachedBindablePropertyAttribute.shared.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 7, 2026 23:47
…eratorPrimitives/AttachedBindablePropertyAttribute.shared.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
TheCodeTraveler and others added 2 commits February 7, 2026 15:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
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

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

@TheCodeTraveler TheCodeTraveler merged commit 4a8740f into main Feb 8, 2026
10 checks passed
@TheCodeTraveler TheCodeTraveler deleted the Resolve-CS0436-Caused-by-Bindable-Property-Attribute branch February 8, 2026 04:58
@github-actions github-actions bot locked and limited conversation to collaborators Feb 9, 2026
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