{"id":15409954,"url":"https://github.com/havendv/viewbasegenerator","last_synced_at":"2025-03-28T02:46:32.606Z","repository":{"id":40605073,"uuid":"418034870","full_name":"HavenDV/ViewBaseGenerator","owner":"HavenDV","description":"Generates boiler-plate code for constructors or ViewBase classes for WPF/UWP/WinUI/Uno projects.","archived":false,"fork":false,"pushed_at":"2023-11-19T08:55:44.000Z","size":283,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T20:07:10.147Z","etag":null,"topics":["code-generator","constructors","generator","initializecomponent","source-generator","uno","uno-platform","uwp","viewbase","winui","winui3","wpf"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HavenDV.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-17T05:55:18.000Z","updated_at":"2023-02-06T16:12:41.000Z","dependencies_parsed_at":"2023-11-19T09:29:09.745Z","dependency_job_id":"f904d7cb-bc23-4eb5-b4eb-3a1a7afc0dc0","html_url":"https://github.com/HavenDV/ViewBaseGenerator","commit_stats":{"total_commits":94,"total_committers":2,"mean_commits":47.0,"dds":0.06382978723404253,"last_synced_commit":"6a91c69ccde338c08fb90921a82e541b40018576"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FViewBaseGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FViewBaseGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FViewBaseGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FViewBaseGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HavenDV","download_url":"https://codeload.github.com/HavenDV/ViewBaseGenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245960646,"owners_count":20700777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","constructors","generator","initializecomponent","source-generator","uno","uno-platform","uwp","viewbase","winui","winui3","wpf"],"created_at":"2024-10-01T16:42:08.996Z","updated_at":"2025-03-28T02:46:32.579Z","avatar_url":"https://github.com/HavenDV.png","language":"C#","readme":"# ViewBaseGenerator\nThe main purpose of the generator is to avoid boilerplate code in the code-behind views files, like this:\n```cs\npublic partial class MainPage\n{\n    public MainPage()\n    {\n        InitializeComponent();\n    }\n}\n```\n\nAt the same time, the generator supports the ability to add your code anywhere through the definition of partial methods for special cases:\n```cs\npublic partial class MainPage\n{\n    partial void BeforeInitializeComponent();\n    partial void AfterInitializeComponent();\n\n    public MainPage()\n    {\n        BeforeInitializeComponent();\n\n        InitializeComponent();\n\n        AfterInitializeComponent();\n    }\n}\n```\n\nI also recommend not deleting .xaml.cs files, but leaving them empty like this:\n```cs\nnamespace YourNamespace.Views;\n\npublic partial class MainView\n{\n}\n```\n\n## Nuget\n\n[![NuGet](https://img.shields.io/nuget/dt/ViewBaseGenerator.svg?style=flat-square\u0026label=ViewBaseGenerator)](https://www.nuget.org/packages/ViewBaseGenerator/)\n\n```\nInstall-Package ViewBaseGenerator\n```\n\n### WPF/UWP/WinUI\n```xml\n  \u003cPropertyGroup\u003e\n    \u003cViewBaseGenerator_Namespace\u003eYourNamespace.Views\u003c/ViewBaseGenerator_Namespace\u003e\n  \u003c/PropertyGroup\u003e\n\n  \u003cItemGroup Label=\"View Constructors\"\u003e\n    \u003cAdditionalFiles Include=\"Views\\**\\*.xaml\" ViewBaseGenerator_GenerateConstructor=\"True\" /\u003e\n  \u003c/ItemGroup\u003e\n\n  \u003cItemGroup Label=\"ViewBase\"\u003e\n    \u003cAdditionalFiles Include=\"Views\\**\\*.xaml.cs\" ViewBaseGenerator_BaseClass=\"ReactiveUI.Uno.ReactiveUserControl\" ViewBaseGenerator_ViewModelNamespace=\"YourNamespace.ViewModels\" /\u003e\n  \u003c/ItemGroup\u003e\n```\n\n### Uno (projects besides UWP/WinUI)\nUno uses Source Generators and there is currently no way to use the output of one generator in another. \nTherefore, the solution is somewhat more complicated:\n1. Create new project like this:\n```xml\n\u003cProject Sdk=\"Microsoft.NET.Sdk\"\u003e\n\n  \u003cPropertyGroup\u003e\n    \u003cTargetFrameworks\u003enetstandard2.0;net6.0-android;net6.0-ios;net6.0-macos;net6.0-maccatalyst\u003c/TargetFrameworks\u003e\n  \u003c/PropertyGroup\u003e\n\n  \u003cPropertyGroup\u003e\n    \u003cViewBaseGenerator_Namespace\u003eYourNamespace.Views\u003c/ViewBaseGenerator_Namespace\u003e\n  \u003c/PropertyGroup\u003e\n\n  \u003cItemGroup Label=\"ViewBase\"\u003e\n    \u003cAdditionalFiles Include=\"..\\..\\shared\\YourNamespace.Shared\\Views\\**\\*.xaml.cs\" ViewBaseGenerator_BaseClass=\"ReactiveUI.Uno.ReactiveUserControl\" ViewBaseGenerator_ViewModelNamespace=\"YourNamespace.ViewModels\" Visible=\"False\" /\u003e\n    \u003cAdditionalFiles Remove=\"..\\..\\shared\\YourNamespace.Shared\\Views\\Navigation\\MainView.xaml.cs\" /\u003e\n    \u003cAdditionalFiles Include=\"..\\..\\shared\\YourNamespace.Shared\\Views\\Navigation\\MainView.xaml.cs\" ViewBaseGenerator_BaseClass=\"ReactiveUI.Uno.ReactivePage\" ViewBaseGenerator_ViewModelNamespace=\"YourNamespace.ViewModels\" Visible=\"False\" /\u003e\n  \u003c/ItemGroup\u003e\n\n  \u003cItemGroup\u003e\n    \u003cPackageReference Include=\"ViewBaseGenerator\" Version=\"1.3.8\"\u003e\n      \u003cPrivateAssets\u003eall\u003c/PrivateAssets\u003e\n      \u003cIncludeAssets\u003eruntime; build; native; contentfiles; analyzers; buildtransitive\u003c/IncludeAssets\u003e\n    \u003c/PackageReference\u003e\n  \u003c/ItemGroup\u003e\n\n  \u003cItemGroup\u003e\n    \u003c!-- Your base class library --\u003e\n    \u003cPackageReference Include=\"ReactiveUI.Uno\" Version=\"16.2.6\" /\u003e\n  \u003c/ItemGroup\u003e\n\n  \u003cItemGroup\u003e\n    \u003c!-- Your core project that contains ViewModels --\u003e\n    \u003cProjectReference Include=\"..\\YourNamespace.Core\\YourNamespace.Core.csproj\" /\u003e\n  \u003c/ItemGroup\u003e\n\t\n\u003c/Project\u003e\n```\n2. Add this project reference to your apps.\n\n## Contacts\n* [mail](mailto:havendv@gmail.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavendv%2Fviewbasegenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhavendv%2Fviewbasegenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavendv%2Fviewbasegenerator/lists"}