{"id":13629561,"url":"https://github.com/DevExpress/DevExpress.Mvvm.CodeGenerators","last_synced_at":"2025-04-17T09:34:40.736Z","repository":{"id":38381628,"uuid":"355126663","full_name":"DevExpress/DevExpress.Mvvm.CodeGenerators","owner":"DevExpress","description":"DevExpress ViewModel generator","archived":false,"fork":false,"pushed_at":"2024-11-13T11:28:48.000Z","size":1714,"stargazers_count":41,"open_issues_count":1,"forks_count":12,"subscribers_count":20,"default_branch":"22.1.1","last_synced_at":"2025-04-14T22:14:38.097Z","etag":null,"topics":["dotnet","mvvm","sourcegenerator","viewmodel","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/DevExpress.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-04-06T09:11:57.000Z","updated_at":"2024-11-13T11:28:53.000Z","dependencies_parsed_at":"2024-11-26T19:01:03.434Z","dependency_job_id":null,"html_url":"https://github.com/DevExpress/DevExpress.Mvvm.CodeGenerators","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevExpress%2FDevExpress.Mvvm.CodeGenerators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevExpress%2FDevExpress.Mvvm.CodeGenerators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevExpress%2FDevExpress.Mvvm.CodeGenerators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevExpress%2FDevExpress.Mvvm.CodeGenerators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevExpress","download_url":"https://codeload.github.com/DevExpress/DevExpress.Mvvm.CodeGenerators/tar.gz/refs/heads/22.1.1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249329886,"owners_count":21252298,"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":["dotnet","mvvm","sourcegenerator","viewmodel","wpf"],"created_at":"2024-08-01T22:01:13.635Z","updated_at":"2025-04-17T09:34:40.720Z","avatar_url":"https://github.com/DevExpress.png","language":"C#","readme":"# View Model Code Generator\n\nThe DevExpress MVVM Framework includes a [source generator](https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.md) that produces boilerplate code for your View Models at compile time. You need to define a stub View Model class that specifies the required logic. Our MVVM Framework analyzes your implementation and applied attributes to generate the final View Model class with all required boilerplate code.\n\n\n\nhttps://user-images.githubusercontent.com/22204671/120662325-b28fc280-c491-11eb-9c8e-f104ee629fde.mp4\n\n\n\n\n\n* **Base View Model**\n    \n    Create a partial class. Add attributes to the class and its fields/methods:\n\n    ```csharp\n    using DevExpress.Mvvm.CodeGenerators;\n\n    [GenerateViewModel]\n    partial class ViewModel {\n        [GenerateProperty]\n        string username;\n        [GenerateProperty]\n        string status;\n\n        [GenerateCommand]\n        void Login() =\u003e Status = \"User: \" + Username;\n        bool CanLogin() =\u003e !string.IsNullOrEmpty(Username);\n    }\n    ```\n    \n* **Generated View Model**\n\n    The generator inspects the base View Model and produces a partial class that complements your implementation with the following boilerplate code:\n    \n    * Properties\n    * Property change notifications\n    * Command declarations\n    * INotifyPropertyChanged, INotifyPropertyChanging, IDataErrorInfo, ISupportServices implementation \n    \n    You can view and debug the generated View Model:\n  \n    ```csharp   \n    partial class ViewModel : INotifyPropertyChanged {\n        public event PropertyChangedEventHandler? PropertyChanged;\n\n        protected void RaisePropertyChanged(PropertyChangedEventArgs e) =\u003e PropertyChanged?.Invoke(this, e);\n\n        public string? Username {\n            get =\u003e username;\n            set {\n                if(EqualityComparer\u003cstring?\u003e.Default.Equals(username, value)) return;\n                username = value;\n                RaisePropertyChanged(UsernameChangedEventArgs);\n            }\n        }\n\n        public string? Status {\n            get =\u003e status;\n            set {\n                if(EqualityComparer\u003cstring?\u003e.Default.Equals(status, value)) return;\n                status = value;\n                RaisePropertyChanged(StatusChangedEventArgs);\n            }\n        }\n\n        DelegateCommand? loginCommand;\n        public DelegateCommand LoginCommand {\n            get =\u003e loginCommand ??= new DelegateCommand(Login, CanLogin, true);\n        }\n\n        static PropertyChangedEventArgs UsernameChangedEventArgs = new PropertyChangedEventArgs(nameof(Username));\n        static PropertyChangedEventArgs StatusChangedEventArgs = new PropertyChangedEventArgs(nameof(Status));\n    }\n    ```\n\n## Prerequisites\n\nYour project should meet the following requirements:\n- C# 9+ (VB is not supported)\n- .NET Framework v4.6.1+ or .NET Core v3.0+\n- Visual Studio v16.9.0+\n\n## Prepare Your Project\n\nPrepare your project as outlined below to enable support for View Models generated at compile time:\n\n1. Add a reference to the **DevExpress.Mvvm.v21.1**+ or install the [DevExpress.Mvvm](https://www.nuget.org/packages/DevExpressMvvm/) NuGet package.  \n2. Install the [DevExpress.Mvvm.CodeGenerators](https://www.nuget.org/packages/DevExpress.Mvvm.CodeGenerators/) NuGet package in your project.\n3. Set the language version to **9** in the **.csproject** file:\n\n    ```xaml\n    \u003cPropertyGroup\u003e\n        \u003cLangVersion\u003e9\u003c/LangVersion\u003e\n    \u003c/PropertyGroup\u003e\n    ```\n\n    For .NET Core projects, set the **IncludePackageReferencesDuringMarkupCompilation** property to **true** additionally:\n\n    ```xaml\n    \u003cPropertyGroup\u003e\n        \u003cIncludePackageReferencesDuringMarkupCompilation\u003etrue\u003c/IncludePackageReferencesDuringMarkupCompilation\u003e\n    \u003c/PropertyGroup\u003e\n    ```\n \n## Documentation\n \n* [View Models Generated at Compile Time](https://docs.devexpress.com/WPF/402989/mvvm-framework/viewmodels/compile-time-generated-viewmodels)\n \n## Example\n \n* [How to: Use View Models Generated at Compile Time](https://github.com/DevExpress-Examples/ViewModelGenerator-Sample)\n\n## Notes on Version Updates and Compatibility\n\nUpdates for the DevExpress.Mvvm.CodeGenerators NuGet package are released independently of the DevExpress component suite release cycle. We do not set specific release dates; we publish a new version when we fix reported issues.     \n\nThe version number for the DevExpress.Mvvm.CodeGenerators package does not need to match that of DevExpress components. The latest available versions are compatible.\n\n## Release Notes\n\n### 22.1.0 \n- The View Model Code Generator now supports the updated WinUI MVVM Framework that is available in the **DevExpress.WinUI.Mvvm.v22.1** assembly. If your **WinUI** project uses **DevExpress.Mvvm.v21.2**, replace it with **DevExpress.WinUI.Mvvm.v22.1**.\n\n### 21.2.2 \n- Our View Model Code Generator now supports the [MVVM Light Toolkit](https://github.com/lbugnion/mvvmlight). \n- We implemented the following suggestion: [Proposal: additional attributes for generated commands](https://github.com/DevExpress/DevExpress.Mvvm.CodeGenerators/issues/14).\n\n### 21.2.1\n\nOur View Model Code Generator now supports the [Prism Library](https://prismlibrary.com).  \n\n### 21.1.3\n\nWe fixed the following issue: [A sealed class generates protected methods](https://github.com/DevExpress/DevExpress.Mvvm.CodeGenerators/issues/8). \n\nIf you use a sealed class, the following members of the generated View Model class will have the **private** access modifier:  \n- RaisePropertyChanged methods\n- RaisePropertyChanging methods\n- ServiceContainers\n- GetService methods\n- GetRequiredService methods\n\n### 21.1.2 \n\n- You can now use the View Model Code Generator in WinUI projects.\t\n- You can add XML comments to a field and a method. The generated property or command now copies these comments.\t\n- We minimized memory allocations and improved the performance. \n\n### 21.1.1\n\n- You can now use Generic and Nested classes when you generate View Models.\n- Use the **ImplementISupportParentViewModel** property to implement [ISupportParentViewModel](https://docs.devexpress.com/WPF/17449/mvvm-framework/viewmodels/viewmodel-relationships-isupportparentviewmodel).\n- Nullable annotation is supported.\n- You can create attributes with custom arguments and apply these attributes to a field. A generated View Model now copies them. \n","funding_links":[],"categories":["Do not want to test 112 ( old ISourceGenerator )","Source Generators"],"sub_categories":["1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category","XAML / WPF / Avalonia"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDevExpress%2FDevExpress.Mvvm.CodeGenerators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDevExpress%2FDevExpress.Mvvm.CodeGenerators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDevExpress%2FDevExpress.Mvvm.CodeGenerators/lists"}