Skip to content

Resolve attached properties from the target type - #364

Merged
wieslawsoltes merged 3 commits into
masterfrom
agent/342-type-resolution
Aug 18, 2026
Merged

wieslawsoltes merged 3 commits into
masterfrom
agent/342-type-resolution

Conversation

@wieslawsoltes

Copy link
Copy Markdown
Owner

Summary

Fixes attached-property resolution in ChangePropertyAction and the shared PropertyHelper.

This resolves both reported manifestations of the same defect:

Root cause

The resolver scanned every loaded assembly and selected the first type whose short name matched the owner segment in (Owner.Property). Selection depended on assembly load order, so unrelated types named Grid could win.

That resolved owner type was then passed to AvaloniaPropertyRegistry.GetRegisteredAttached. Avalonia indexes attached properties by the type they can be attached to—the target control type—not by the property owner type. This made the lookup incorrect even when the owner type happened to resolve as intended.

Changes

  • Remove the loaded-assembly scan and Assembly.GetTypes() fallback.
  • Query registered attached and inherited properties using the actual target object's type.
  • Continue matching the requested owner and property names against the registered property metadata.
  • Add a regression with an unrelated same-named Grid type to prove assembly load order cannot affect resolution.
  • Add a regression where the attached-property owner is unrelated to the registered target type.
  • Document the (Owner.Property) syntax with a Grid.Column example.

Performance and compatibility

The new path avoids enumerating loaded assemblies and allocating the LINQ pipelines previously used for every attached-property update. Existing regular-property and inherited-property behavior remains covered by the full suite.

Validation

  • Focused attached-property regressions: 2 passed
  • Xaml.Behaviors.Interactivity.UnitTests: 93 passed
  • Xaml.Behaviors.Interactions.UnitTests: 91 passed, 2 existing skipped
  • git diff --check: clean

Closes #342
Closes #343

@wieslawsoltes
wieslawsoltes marked this pull request as ready for review July 14, 2026 22:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffe0234ca2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Xaml.Behaviors.Interactivity/Helpers/PropertyHelper.cs
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jul 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e85cdcca07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Xaml.Behaviors.Interactivity/Helpers/PropertyHelper.cs
@wieslawsoltes
wieslawsoltes merged commit d7eaabc into master Aug 18, 2026
3 checks passed
@wieslawsoltes
wieslawsoltes deleted the agent/342-type-resolution branch August 18, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant