CastelloBranco.LocatorGenerator 2.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package CastelloBranco.LocatorGenerator --version 2.0.9                
NuGet\Install-Package CastelloBranco.LocatorGenerator -Version 2.0.9                
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="CastelloBranco.LocatorGenerator" Version="2.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CastelloBranco.LocatorGenerator --version 2.0.9                
#r "nuget: CastelloBranco.LocatorGenerator, 2.0.9"                
#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.
// Install CastelloBranco.LocatorGenerator as a Cake Addin
#addin nuget:?package=CastelloBranco.LocatorGenerator&version=2.0.9

// Install CastelloBranco.LocatorGenerator as a Cake Tool
#tool nuget:?package=CastelloBranco.LocatorGenerator&version=2.0.9                

CastelloBranco.LocatorGenerator

CastelloBranco.LocatorGenerator is a source generator designed to automatically generate the necessary code to locate and instantiate ViewModels marked with a special attribute in Avalonia projects.

Usage

Inports nuget Package AutoRegisterInject and decorate yours views and viewmodels with

[RegisterTransient] [RegisterSingleton] [RegisterScoped] [RegisterHostedService]

Code Generator

This tool scans projects for classes and generates a ViewLocator.g.cs file to resolve and inject dependencies automatically using the CommunityToolkit.Mvvm library.

Setup

NuGet Package:

1) Add nuget packeges to the project that will use the generated locator.
   Microsoft.Extensions.DependencyInjection;
   CommunityToolkit.Mvvm 
   AutoRegisterInject 

2) Add the `CastelloBranco.LocatorGenerator` package to the project that will use the generated locator.

Usage

  1. Decorate yours views and viewmodels with

[RegisterTransient] [RegisterSingleton] [RegisterScoped] [RegisterHostedService]

  1. in xaml files add the following namespaces and AutoWrireViewModel.Enabled="True"

<UserControl 
    ...
    xmlns:l="using:your_root_namespace"
    xmlns:views="using:your_Views_namespace_"
    xmlns:vm="using:your_ViewModels_namespace_"
    l:AutoWireViewModel.Enabled="True"
    x:DataType="vm:MainViewViewModel"
    >
  1. Add the following code to the App.xaml file

<Application ...
             xmlns:l="using:your_root_namespace"
             ... >
    <Application.DataTemplates>
        <l:ViewLocator />
    </Application.DataTemplates>

License

MIT

Contribution

Contributions are welcome! Please follow the pull request process and review our contribution policy.

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. 
.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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.3 25 2/11/2025
2.1.2 20 2/11/2025
2.1.1 24 2/11/2025
2.1.0 23 2/11/2025
2.0.9 37 2/11/2025
1.0.4 104 11/12/2024
1.0.0 34 2/11/2025