Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/havendv/viewbasegenerator

Generates boiler-plate code for constructors or ViewBase classes for WPF/UWP/WinUI/Uno projects.
https://github.com/havendv/viewbasegenerator

code-generator constructors generator initializecomponent source-generator uno uno-platform uwp viewbase winui winui3 wpf

Last synced: 19 days ago
JSON representation

Generates boiler-plate code for constructors or ViewBase classes for WPF/UWP/WinUI/Uno projects.

Awesome Lists containing this project

README

        

# ViewBaseGenerator
The main purpose of the generator is to avoid boilerplate code in the code-behind views files, like this:
```cs
public partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
}
```

At the same time, the generator supports the ability to add your code anywhere through the definition of partial methods for special cases:
```cs
public partial class MainPage
{
partial void BeforeInitializeComponent();
partial void AfterInitializeComponent();

public MainPage()
{
BeforeInitializeComponent();

InitializeComponent();

AfterInitializeComponent();
}
}
```

I also recommend not deleting .xaml.cs files, but leaving them empty like this:
```cs
namespace YourNamespace.Views;

public partial class MainView
{
}
```

## Nuget

[![NuGet](https://img.shields.io/nuget/dt/ViewBaseGenerator.svg?style=flat-square&label=ViewBaseGenerator)](https://www.nuget.org/packages/ViewBaseGenerator/)

```
Install-Package ViewBaseGenerator
```

### WPF/UWP/WinUI
```xml

YourNamespace.Views






```

### Uno (projects besides UWP/WinUI)
Uno uses Source Generators and there is currently no way to use the output of one generator in another.
Therefore, the solution is somewhat more complicated:
1. Create new project like this:
```xml


netstandard2.0;net6.0-android;net6.0-ios;net6.0-macos;net6.0-maccatalyst


YourNamespace.Views







all
runtime; build; native; contentfiles; analyzers; buildtransitive








```
2. Add this project reference to your apps.

## Contacts
* [mail](mailto:[email protected])