ConvMVVM3.SourceGenerator 1.0.3

dotnet add package ConvMVVM3.SourceGenerator --version 1.0.3
                    
NuGet\Install-Package ConvMVVM3.SourceGenerator -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ConvMVVM3.SourceGenerator" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ConvMVVM3.SourceGenerator" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="ConvMVVM3.SourceGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ConvMVVM3.SourceGenerator --version 1.0.3
                    
#r "nuget: ConvMVVM3.SourceGenerator, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ConvMVVM3.SourceGenerator@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ConvMVVM3.SourceGenerator&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=ConvMVVM3.SourceGenerator&version=1.0.3
                    
Install as a Cake Tool

<p align="center"> <img src="https://github.com/gellston/ConvMVVM3/blob/main/logo.png?raw=true" alt="ConvMVVM3 Logo" width="400"/> </p>

ConvMVVM3 (Convergence MVVM3) is a modern, cross-platform MVVM framework that combines the best features from Prism and Community Toolkit while adding unique innovations.


πŸ“Œ XAML Namespace Mapping

ConvMVVM3 exposes a single XAML XML namespace for a clean, consistent XAML experience:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:convMVVM3="https://github.com/gellston/ConvMVVM3"
    convMVVM3:ViewModelLocator.AutoWireViewModel="True">
</Window>
  • xmlns:convMVVM3="https://github.com/gellston/ConvMVVM3" β†’ ConvMVVM3 XAML features (Regions, ViewModelLocator, Behaviors/Interactivity, etc.)
  • convMVVM3:ViewModelLocator.AutoWireViewModel="True" β†’ ViewModel auto-wiring (Prism-like)

✨ Key Differentiators from Prism & Community Toolkit

πŸš€ UIDispatcher (UNIQUE - Cross-Platform)

Microsoft-compatible UI thread dispatcher for multiple platforms:

// Setup - Available for WPF, MAUI, Avalonia, WinUI
services.AddWPFUIDispatcher();      // WPF

// Usage - Cross-platform compatible
await dispatcher.InvokeAsync(() => Title = "Updated");

πŸ”Œ Smart Dependency Injection (UNIQUE - Built-in)

Lightweight service container with addon system - No external DI required:

// Built-in container - Zero external dependencies
services.AddSingleton<IMyService, MyService>();

πŸ“‘ WeakReference Messenger (Memory-Safe, Cross-Platform)

Thread-safe messaging with automatic cleanup:

// Automatic weak references - Platform-agnostic
WeakReferenceMessenger.Default.Send<Message>(this, newData);

🎯 Region System (Prism-inspired, Cross-Platform)

Built-in region management for multiple frameworks:


<ContentControl convMVVM3:RegionPlugin.RegionName="MainContent" />

⚑ Source Generator (Community Toolkit-inspired)

Automatic property and command generation with enhanced features:

[ObservableProperty] private string title;       // Generates Title property
[RelayCommand] private void Save();              // Generates SaveCommand
[AsyncRelayCommand] private async Task Load();   // Generates LoadCommand

πŸ—οΈ Architecture Overview

Core MVVM Components (Platform-Agnostic)

ConvMVVM3.Core/
β”œβ”€β”€ ObservableObject              # Base class with INotifyPropertyChanged
β”œβ”€β”€ ObservableRecipient           # Message recipient base class
β”œβ”€β”€ UIDispatcher                  # Cross-platform dispatcher interface
β”œβ”€β”€ WeakReferenceMessenger        # Memory-safe messaging system
β”œβ”€β”€ Commands/
β”‚   β”œβ”€β”€ RelayCommand              # Synchronous command implementation
β”‚   └── AsyncRelayCommand         # Async command with cancellation
└── DependencyInjection/          # Built-in DI container

WPF Implementation (One of Many Platforms)

ConvMVVM3.WPF/                    # WPF-specific implementation
β”œβ”€β”€ Regions/                      # Region system (Prism-inspired)
β”œβ”€β”€ WPFUIDispatcher               # WPF-specific dispatcher
β”œβ”€β”€ Interactivity/                # Behaviors / triggers / actions
└── WeakEventManager              # Memory-efficient event handling

Source Generation (Cross-Platform)

ConvMVVM3.SourceGenerator/
β”œβ”€β”€ ObservableProperty generation # Auto property implementation
β”œβ”€β”€ RelayCommand generation       # Auto command creation
β”œβ”€β”€ Dependency tracking           # Smart property notification
└── Compile-time validation       # Early error detection

πŸ“ Project Structure

ConvMVVM3.Core/                   # Platform-agnostic MVVM library
ConvMVVM3.SourceGenerator/        # Cross-platform source generator
ConvMVVM3.WPF/                    # WPF-specific interactivity + regions
ConvMVVM3.Host/                   # DI host implementation
ConvMVVM3.WPF.Tests/              # WPF unit tests
ConvMVVM3.Tests/                  # Core unit tests

πŸ› οΈ Installation

dotnet add package ConvMVVM3

πŸš€ Quick Start

1) Basic ViewModel with Cross-Platform Generation

// Works on ALL supported platforms
public partial class MainViewModel : ObservableObject
{
    [ObservableProperty]
    private string title = "Hello ConvMVVM3!";

    [RelayCommand]
    private void ShowMessage() => MessageBox.Show(Title);

    [AsyncRelayCommand]
    private async Task LoadDataAsync()
    {
        Title = "Loading...";
        await Task.Delay(1000);
        Title = "Data Loaded!";
    }
}

2) ViewModelLocator (AutoWireViewModel)

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:convMVVM3="https://github.com/gellston/ConvMVVM3"
    convMVVM3:ViewModelLocator.AutoWireViewModel="True">
    
</Window>

3) Cross-Platform UIDispatcher Integration

// Setup varies by platform
services.AddWPFUIDispatcher();       // WPF

// Usage is identical across platforms
public partial class MyViewModel : ObservableObject
{
    private readonly IUIDispatcher _dispatcher;

    public MyViewModel(IUIDispatcher dispatcher)
    {
        _dispatcher = dispatcher;
    }

    [AsyncRelayCommand]
    private async Task UpdateFromBackgroundAsync()
    {
        var data = await Task.Run(() => GetHeavyData());

        // Thread-safe UI update (cross-platform)
        await _dispatcher.InvokeAsync(() => Title = data);
    }
}

4) Cross-Platform Region Management


<Grid>
    <ContentControl convMVVM3:RegionPlugin.RegionName="MainContent" />
</Grid>
// Platform-agnostic navigation
_regionManager.RequestNavigate("MainContent", typeof(HomeViewModel));

5) Memory-Safe Cross-Platform Messaging

// Sender (all platforms)
WeakReferenceMessenger.Default.Send<DataUpdatedMessage>(this, newData);

// Receiver (auto-cleanup, all platforms)
public partial class MyViewModel : ObservableObject, IRecipient<DataUpdatedMessage>
{
    public void Receive(DataUpdatedMessage message)
    {
        Title = message.Data;
    }
}

6) WPF Interactivity / Behaviors

<Button Content="Click Me">
    <convMVVM3:Interaction.Triggers>
        <convMVVM3:EventTrigger EventName="Click">
            <convMVVM3:InvokeCommandAction Command="{Binding SaveCommand}" />
        </convMVVM3:EventTrigger>
    </convMVVM3:Interaction.Triggers>
</Button>

🧰 Helpful Utilities

This section includes a few practical helpers used frequently in Prism-style MVVM apps:

  • ConvMVVM3.Core.Mvvm.Threading
  • ConvMVVM3.Core.Mvvm.Collections
  • ConvMVVM3.Host.DependencyInjection

A) BusyScope β€” ConvMVVM3.Core.Mvvm.Threading

Use a scope to ensure IsBusy is always restored (even if an exception occurs).
Recommended for simple β€œsingle operation” flows.

using ConvMVVM3.Core.Mvvm.Threading;

// In your ViewModel
private bool _isBusy;
public bool IsBusy
{
    get => _isBusy;
    set { _isBusy = value; /* RaisePropertyChanged */ }
}

public async Task RefreshAsync()
{
    using (BusyScope.Enter(v => IsBusy = v))
    {
        await LoadAsync();
    }
}

Recommended when operations can overlap (nested calls, multiple async commands).

using ConvMVVM3.Core.Mvvm.Threading;

private int _busyCount;
private bool _isBusy;
public bool IsBusy
{
    get => _isBusy;
    set { _isBusy = value; /* RaisePropertyChanged */ }
}

public async Task RefreshAsync()
{
    using (BusyCounterScope.Enter(
        getCount: () => _busyCount,
        setCount: v => _busyCount = v,
        setBusy:  v => IsBusy = v))
    {
        await LoadAsync();
    }
}

C) OperationGuard β€” ConvMVVM3.Core.Mvvm.Threading

Prevents re-entrancy (double-click save, multiple async executions).
Combine it with BusyScope/BusyCounterScope for a great UX.

using ConvMVVM3.Core.Mvvm.Threading;

private readonly OperationGuard _saveGuard = new OperationGuard();
private int _busyCount;

public Task SaveAsync()
{
    return _saveGuard.RunAsync(async () =>
    {
        using (BusyCounterScope.Enter(
            () => _busyCount,
            v => _busyCount = v,
            v => IsBusy = v))
        {
            await SaveAsyncCore();
        }
    });
}

D) ObservableRangeCollection β€” ConvMVVM3.Core.Mvvm.Collections

Use AddRange/ReplaceRange to avoid thousands of per-item collection change notifications.

using ConvMVVM3.Core.Mvvm.Collections;

public ObservableRangeCollection<ItemViewModel> Items { get; } = new();

public async Task LoadItemsAsync()
{
    var items = await LoadFromServerAsync();

    // One reset notification instead of N adds
    Items.ReplaceRange(items);
}

E) ActivatorUtilities β€” ConvMVVM3.Host.DependencyInjection

ActivatorUtilities helps create objects by mixing:

  • DI-resolved services from IServiceResolver
  • runtime arguments you provide (e.g., IDs, parameters, view references)
using ConvMVVM3.Core.DependencyInjection.Abstractions;
using ConvMVVM3.Host.DependencyInjection;

// Example types
public sealed class UserDetailsViewModel
{
    public UserDetailsViewModel(IUserService service, int userId)
    {
        // service comes from DI, userId comes from runtime args
    }
}

public static class Example
{
    public static void CreateWithRuntimeArgs(IServiceResolver resolver)
    {
        // 1) CreateInstance: DI + runtime args
        var vm = (UserDetailsViewModel)ActivatorUtilities.CreateInstance(
            resolver,
            typeof(UserDetailsViewModel),
            123);

        // 2) GetServiceOrCreateInstance: prefer registered instance, otherwise create
        var shell = ActivatorUtilities.GetServiceOrCreateInstance<MainShellViewModel>(resolver);

        // 3) CreateFactory: preselect ctor + argument mapping for speed
        var factory = ActivatorUtilities.CreateFactory(
            typeof(UserDetailsViewModel),
            new[] { typeof(int) });

        var vmFast = (UserDetailsViewModel)factory(resolver, new object[] { 456 });
    }
}

Note: The class name is ActivatorUtilities (not ActivityUtility).


🧩 Bootstrapper

ConvMVVM3 supports a Prism-style Bootstrapper flow for registering modules, building the shell, and initializing regions/services.

public class AppBootStrapper : Bootstrapper
{
    protected override void ConfigureRegion(IRegionManager regionManager)
    {
    }

    protected override Window CreateShell(IServiceContainer provider)
    {
        return (Window)provider.GetService("MainWindowView");
    }

    protected override void OnInitialized(IServiceContainer provider)
    {
    }

    protected override void RegisterModules()
    {
        this.RegisterModule<AModule>();
        this.RegisterModule<BModule>();
        this.RegisterModule<CModule>();
        this.RegisterModule<MainModule>();
    }

    protected override void RegisterServices(IServiceRegistry container)
    {
    }
}

🎯 Platform Support Matrix

Feature WPF MAUI Avalonia WinUI UNO
Core MVVM βœ… βœ… βœ… βœ… βœ…
UIDispatcher βœ… πŸ”„ πŸ”„ πŸ”„ πŸ”„
Source Generator βœ… βœ… βœ… βœ… βœ…
Region System βœ… πŸ”„ πŸ”„ πŸ”„ πŸ”„
Built-in DI βœ… βœ… βœ… βœ… βœ…
Weak Messenger βœ… βœ… βœ… βœ… βœ…
WPF Interactivity βœ… ❌ ❌ ❌ ❌
Platform Interactivity ❌ πŸ”„ πŸ”„ πŸ”„ πŸ”„

βœ… Available | πŸ”„ Planned | ❌ Not applicable


πŸ“„ License

MIT License - see LICENSE file


ConvMVVM3: Modern, cross-platform MVVM framework that bridges the gap between Prism's power and Community Toolkit's simplicity while adding unique cross-platform innovations.

Future Roadmap: MAUI, Avalonia, WinUI, and UNO Platform support coming soon!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ConvMVVM3.SourceGenerator:

Package Downloads
ConvMVVM3.WPF

ConvMVVM3 Core MVVM library (platform-agnostic).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 97 2/9/2026
1.0.2 88 2/8/2026
1.0.1 94 2/8/2026