PrismCommands.Fody
1.0.6
Prefix Reserved
See the version list below for details.
dotnet add package PrismCommands.Fody --version 1.0.6
NuGet\Install-Package PrismCommands.Fody -Version 1.0.6
<PackageReference Include="PrismCommands.Fody" Version="1.0.6" />
paket add PrismCommands.Fody --version 1.0.6
#r "nuget: PrismCommands.Fody, 1.0.6"
// Install PrismCommands.Fody as a Cake Addin #addin nuget:?package=PrismCommands.Fody&version=1.0.6 // Install PrismCommands.Fody as a Cake Tool #tool nuget:?package=PrismCommands.Fody&version=1.0.6
PrismCommands.Fody
PrismCommands.Fody
is a Fody plugin that provides a simple way to replace methods with Prism DelegateCommand properties at compile time.
This is useful when using the Prism library to build applications with the Model-View-ViewModel (MVVM) architecture. DelegateCommand is a class provided by Prism that implements the ICommand interface and allows you to bind a command from the view to a method in the view model.
Installation
- Install the
PrismCommands.Fody
NuGet package in your project. - Add
<PrismCommands />
to yourFodyWeavers.xml
file in the project's root directory. This step is necessary for Fody to enable thePrismCommands.Fody
plugin during the build process. - Add a
[DelegateCommand]
attribute to any method in your code that you want to replace with a DelegateCommand property. - Build your project. The methods with the
[DelegateCommand]
attribute will be replaced with DelegateCommand properties.
Example
public class MyViewModel
{
[DelegateCommand]
public void DoSomething()
{
// Do something here.
}
[DelegateCommand]
public void DoSomethingWithArg(string arg)
{
// Do something with arg here.
}
}
After building, each method marked with the [DelegateCommand]
attribute will be replaced with a corresponding DelegateCommand
property named using the "{MethodName}Command" pattern.
For example, if you have a MyViewModel
class with methods named DoSomething
and DoSomethingWithArg
marked with the [DelegateCommand]
attribute, after building, these methods will be replaced with properties named DoSomethingCommand
and DoSomethingWithArgCommand
.
public class MyViewModel
{
public DelegateCommand DoSomethingCommand { get; }
public DelegateCommand<string> DoSomethingWithArgCommand { get; }
public MyViewModel()
{
DoSomethingCommand = new DelegateCommand(DoSomething);
DoSomethingWithArgCommand = new DelegateCommand<string>(DoSomethingWithArg);
}
private void DoSomething()
{
// Do something here.
}
private void DoSomethingWithArg(string arg)
{
// Do something with arg here.
}
}
Thus, you can use the DoSomethingCommand
and DoSomethingWithArgCommand
properties to bind the commands to the view.
Note that if you have a method with a name that matches the property name created by PrismCommands.Fody
, this can lead to conflicts and build errors. To avoid this, avoid using strings in method names that match the "Command" string.
How it works
PrismCommands.Fody
uses the Mono.Cecil library to modify the assembly at compile time. It scans the assembly for methods with the [DelegateCommand]
attribute and replaces them with DelegateCommand properties.
The implementation details can be found in the ModuleWeaver
class.
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue. If you want to contribute code, please fork the repository and submit a pull request.
License
PrismCommands.Fody
is licensed under the MIT License.
Contributors
The following individuals have contributed to the development and maintenance of PrismCommands.Fody
:
- Vitaly Kuzyaev (@vitkuz573): Developer of the plugin. Implemented the core functionality of the plugin, wrote the initial codebase, and provided ongoing maintenance and support.
- OpenAI ChatGPT (@openai/chatgpt): Provided assistance with code development and readme composition. Helped with code review, testing, and provided feedback and suggestions for improving the documentation and user experience.
Product | Versions 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. |
.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 is compatible. |
.NET Framework | net452 is compatible. net46 was computed. 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. |
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.0.8 | 253 | 7/5/2023 |
2.0.7 | 148 | 5/31/2023 |
2.0.6 | 159 | 5/2/2023 |
2.0.5 | 173 | 4/25/2023 |
2.0.4 | 176 | 4/23/2023 |
2.0.1 | 190 | 4/12/2023 |
2.0.0 | 194 | 4/10/2023 |
1.0.10 | 202 | 4/9/2023 |
1.0.9 | 192 | 4/8/2023 |
1.0.8 | 228 | 4/7/2023 |
1.0.6 | 209 | 4/6/2023 |
1.0.3 | 189 | 4/5/2023 |
1.0.2 | 201 | 4/5/2023 |
1.0.1 | 191 | 4/5/2023 |
1.0.0 | 193 | 4/5/2023 |