mirror of
https://github.com/safishamsi/graphify.git
synced 2026-07-13 19:07:10 +00:00
905e0a7a2e
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) <noreply@anthropic.com>
31 lines
561 B
C#
31 lines
561 B
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace Demo.ViewModels;
|
|
|
|
public partial class ToolkitViewModel : ObservableObject
|
|
{
|
|
[ObservableProperty]
|
|
private string userName = "";
|
|
|
|
[ObservableProperty] private string email = "";
|
|
|
|
// ObservableProperty
|
|
private string ignoredName = "";
|
|
|
|
[RelayCommand]
|
|
private async Task SaveAsync()
|
|
{
|
|
await Task.CompletedTask;
|
|
}
|
|
|
|
[RelayCommand] private void Refresh()
|
|
{
|
|
}
|
|
|
|
// RelayCommand
|
|
private void Ignored()
|
|
{
|
|
}
|
|
}
|