Repository navigation
feat: add XAML extraction support - #1460
MikeKatsoulakis wants to merge 1 commit into
Conversation
…#1460) Makes .xaml a first-class code input. extract_xaml() uses stdlib XML (no new parser dependency) behind the same DOCTYPE/ENTITY and size guards as the .csproj extractor, and captures: the root element, named controls (x:Name/Name) and their control types, {Binding ...} references, x:Class, and -- the useful part -- a bridge from the view markup to its .xaml.cs code-behind by resolving event-handler attributes to the matching methods on the partial class. Ported from PR #1460 by @MikeKatsoulakis onto current v8. Maintainer hardening on top of the original PR: event resolution is now gated so it can't fabricate edges. The original matched any attribute value against code-behind method names, so Content="Save" next to a business method Save(), or Tag="<a-handler-name>", produced spurious "event" edges. Resolution now requires (a) the attribute is not a known free-form/identity property (Content, Text, Tag, Title, ToolTip, Header, ...), (b) the value is a bare identifier, and (c) the matched method actually has the .NET event-handler signature (object sender, <T>EventArgs e) -- read from the code-behind source since the C# extractor does not record parameter lists on method nodes. Added regression tests for both false-positive cases. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Thanks @MikeKatsoulakis — this is a genuinely useful addition, and the code-behind bridge (resolving Landed on One change I made on top before merging: tightened event-handler resolution so it can't create false edges. The original matched any attribute value against code-behind method names, so in real WPF a property like Full suite (2417 passed) + skillgen guards green, and I verified the end-to-end bridge on the fixture (3 real events, The deferred items you listed (resource dictionaries, styles/templates, converters, ViewModel inference, cross-file view↔VM resolution) are good follow-ups if you want to keep going. Closing as merged-by-port — thanks for the contribution. |
…rences (#1473) Builds on the initial XAML support (#1460). Resolves a view to its ViewModel from an explicit <Window.DataContext><vm:MainViewModel/>, a design-time d:DataContext="{d:DesignInstance Type=...}", the View->ViewModel naming convention, or Prism ViewModelLocator.AutoWireViewModel="True". Resolution is always against an actually-extracted C# class node, so a name matching no class (or an ambiguous 2+) emits no edge -- explicit DataContext is EXTRACTED, convention/Prism are INFERRED. Also extracts binding paths ({Binding User.Name}, Path=Order.Total), commands (Command="{Binding SaveCommand}"), converters, and CommunityToolkit [ObservableProperty]/[RelayCommand] generated members. The #1460 event-handler hardening is preserved unchanged: events still resolve only to methods with a .NET (object sender, ...EventArgs e) signature, and the free-form-attribute denylist still prevents values like Content="Save" from fabricating event edges (both regression tests still pass). ViewModel discovery is bounded to the active extraction root. Ported from PR #1473 by @MikeKatsoulakis (clean 3-way merge onto current v8). Maintainer fix on top: the CommunityToolkit member reader now reads the code-behind with errors="replace", so a non-UTF8 ViewModel .cs can't raise UnicodeDecodeError and abort extract_xaml (matches every other reader in the module). Added a regression test for that case. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Dates the 0.8.50 CHANGELOG and bumps the version. Highlights: WPF/XAML extraction + ViewModel/binding links (#1460/#1473), Objective-C relationship fixes (#1475), .vue SFC grammar fix (#1468), Metal shader indexing (#1480), Java field/annotation references (#1485/#1487), portable wiki links (#1444), *_BASE_URL backend overrides (#1458), non-streaming OpenAI-compatible calls (#1223), reflect --if-stale sidecar freshness (#1470), label --missing-only (#1481), canvas grid + case-fold dedup (#1452/#1453), the Read|Glob hook extension fix (#1463), and the no-API-key skill clarification (#1461). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…Graphify-Labs#1460) Makes .xaml a first-class code input. extract_xaml() uses stdlib XML (no new parser dependency) behind the same DOCTYPE/ENTITY and size guards as the .csproj extractor, and captures: the root element, named controls (x:Name/Name) and their control types, {Binding ...} references, x:Class, and -- the useful part -- a bridge from the view markup to its .xaml.cs code-behind by resolving event-handler attributes to the matching methods on the partial class. Ported from PR Graphify-Labs#1460 by @MikeKatsoulakis onto current v8. Maintainer hardening on top of the original PR: event resolution is now gated so it can't fabricate edges. The original matched any attribute value against code-behind method names, so Content="Save" next to a business method Save(), or Tag="<a-handler-name>", produced spurious "event" edges. Resolution now requires (a) the attribute is not a known free-form/identity property (Content, Text, Tag, Title, ToolTip, Header, ...), (b) the value is a bare identifier, and (c) the matched method actually has the .NET event-handler signature (object sender, <T>EventArgs e) -- read from the code-behind source since the C# extractor does not record parameter lists on method nodes. Added regression tests for both false-positive cases. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…rences (Graphify-Labs#1473) Builds on the initial XAML support (Graphify-Labs#1460). Resolves a view to its ViewModel from an explicit <Window.DataContext><vm:MainViewModel/>, a design-time d:DataContext="{d:DesignInstance Type=...}", the View->ViewModel naming convention, or Prism ViewModelLocator.AutoWireViewModel="True". Resolution is always against an actually-extracted C# class node, so a name matching no class (or an ambiguous 2+) emits no edge -- explicit DataContext is EXTRACTED, convention/Prism are INFERRED. Also extracts binding paths ({Binding User.Name}, Path=Order.Total), commands (Command="{Binding SaveCommand}"), converters, and CommunityToolkit [ObservableProperty]/[RelayCommand] generated members. The Graphify-Labs#1460 event-handler hardening is preserved unchanged: events still resolve only to methods with a .NET (object sender, ...EventArgs e) signature, and the free-form-attribute denylist still prevents values like Content="Save" from fabricating event edges (both regression tests still pass). ViewModel discovery is bounded to the active extraction root. Ported from PR Graphify-Labs#1473 by @MikeKatsoulakis (clean 3-way merge onto current v8). Maintainer fix on top: the CommunityToolkit member reader now reads the code-behind with errors="replace", so a non-UTF8 ViewModel .cs can't raise UnicodeDecodeError and abort extract_xaml (matches every other reader in the module). Added a regression test for that case. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Dates the 0.8.50 CHANGELOG and bumps the version. Highlights: WPF/XAML extraction + ViewModel/binding links (Graphify-Labs#1460/Graphify-Labs#1473), Objective-C relationship fixes (Graphify-Labs#1475), .vue SFC grammar fix (Graphify-Labs#1468), Metal shader indexing (Graphify-Labs#1480), Java field/annotation references (Graphify-Labs#1485/Graphify-Labs#1487), portable wiki links (Graphify-Labs#1444), *_BASE_URL backend overrides (Graphify-Labs#1458), non-streaming OpenAI-compatible calls (Graphify-Labs#1223), reflect --if-stale sidecar freshness (Graphify-Labs#1470), label --missing-only (Graphify-Labs#1481), canvas grid + case-fold dedup (Graphify-Labs#1452/Graphify-Labs#1453), the Read|Glob hook extension fix (Graphify-Labs#1463), and the no-API-key skill clarification (Graphify-Labs#1461). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Refs #1456.
What
Adds basic WPF/XAML structural extraction without a new parser dependency.
This PR makes
.xamlfiles first-class code inputs and extracts:x:Name/Name{Binding ...}referencesx:Classreferences.xaml.cspartial classWhy
WPF projects keep important frontend structure in XAML, but graphify currently skips
.xamlfiles. That means UI controls, bindings, view classes, and event handlers are invisible in the graph even though the matching C# code-behind is already extractable.Resolving
x:Classand event handlers gives the graph a useful bridge from the view markup to the C# partial class and methods without turning this into a full WPF analyzer.XAML coverage in this PR
Added now:
.xamlfile discovery and dispatchWindow,UserControl, etc.)x:NameorNameButton,TextBox,StackPanel, etc.){Binding PropertyName}referencesx:Class="Namespace.Type"links to the matching.xaml.cspartial class when presentDeferred deeper analysis:
StaticResource/DynamicResourceand resource dictionary resolutionDataContext/ ViewModel inferenceChanges
graphify/detect.py: add.xamltoCODE_EXTENSIONSgraphify/extract.py: addextract_xaml()and dispatch registrationtests/fixtures/sample.xaml/sample.xaml.cs: add a small WPF fixture pairtests/test_dotnet.py: cover XAML class resolution, named controls, bindings, and event-handler linkstests/test_languages.py: add the contribution-path XAML smoke testREADME.md: document.xamlin the supported file extensions tableTesting
uv run pytest tests/test_dotnet.py tests/test_languages.py::test_xaml_finds_class_and_event_references -quv run ruff check graphify tests --select E9,F63,F7,F82Full
uv run pytest tests/ -qwas attempted locally on Windows, but existing unrelated Windows/path and install/skillgen failures prevent a clean full-suite result on this machine.