{"id":13628888,"url":"https://github.com/SzymonHalucha/Minerals.AutoMixins","last_synced_at":"2025-04-17T04:32:34.156Z","repository":{"id":230370805,"uuid":"770912912","full_name":"SzymonHalucha/Minerals.AutoMixins","owner":"SzymonHalucha","description":"Package for automatic mixin design pattern generation using an incremental source generator","archived":false,"fork":false,"pushed_at":"2024-05-16T19:33:54.000Z","size":46,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T19:41:19.219Z","etag":null,"topics":["csharp","csharp-sourcegenerator","design-patterns","dotnet","mixin","mixins","roslyn"],"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/SzymonHalucha.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":"2024-03-12T11:32:24.000Z","updated_at":"2025-03-15T01:02:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c05122a-a073-44be-a866-67070f74a098","html_url":"https://github.com/SzymonHalucha/Minerals.AutoMixins","commit_stats":null,"previous_names":["szymonhalucha/minerals.automixins"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SzymonHalucha%2FMinerals.AutoMixins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SzymonHalucha%2FMinerals.AutoMixins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SzymonHalucha%2FMinerals.AutoMixins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SzymonHalucha%2FMinerals.AutoMixins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SzymonHalucha","download_url":"https://codeload.github.com/SzymonHalucha/Minerals.AutoMixins/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249315999,"owners_count":21249871,"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":["csharp","csharp-sourcegenerator","design-patterns","dotnet","mixin","mixins","roslyn"],"created_at":"2024-08-01T22:00:58.996Z","updated_at":"2025-04-17T04:32:32.809Z","avatar_url":"https://github.com/SzymonHalucha.png","language":"C#","funding_links":[],"categories":["Content","Source Generators"],"sub_categories":["140. [Minerals.AutoMixins](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Minerals.AutoMixins) , in the [Mixin](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mixin) category","Patterns"],"readme":"# Minerals.AutoMixins\n\n![GitHub License](https://img.shields.io/github/license/SzymonHalucha/Minerals.AutoMixins?style=for-the-badge)\n![NuGet Version](https://img.shields.io/nuget/v/Minerals.AutoMixins?style=for-the-badge)\n![NuGet Downloads](https://img.shields.io/nuget/dt/Minerals.AutoMixins?style=for-the-badge)\n\n[Package on nuget.org](https://www.nuget.org/packages/Minerals.AutoMixins/)\n\nThis NuGet package provides a capability to automatically generate a [mix-in](https://en.wikipedia.org/wiki/Mixin) design pattern for C# classes by using only one attribute. This allows you to easily extend the functionality of existing classes.\n\n## Features\n\n- **Easy mix-in definition:** Mix-in object are defined by using the ```[GenerateMixin]``` attribute.\n- **Easy addition of mix-ins to a class:** To add a mix-in object to a class, use the ```[AddMixin(typeof(ExampleMixinClass))]``` attribute.\n- **Optimized code generation:** The package uses an incremental source generator, so it doesn't significantly slow down the compilation process.\n- **Compatibility with .NET Standard 2.0 and C# 7.3+:** Works on a wide range of platforms and development environments.\n\n## Installation\n\nAdd the Minerals.AutoMixins nuget package to your C# project using the following methods:\n\n### 1. Project file definition\n\n```xml\n\u003cPackageReference Include=\"Minerals.AutoMixins\" Version=\"0.2.1\" /\u003e\n```\n\n### 2. dotnet command\n\n```bat\ndotnet add package Minerals.AutoMixins\n```\n\n## Why choose this package instead of the Default Interface Implementation?\n\nBecause the C# language option called \"Default Interface Implementation\", has limited runtime platform support. The Minerals.AutoMixins package is compatible with ```netstandard2.0``` and C# language version 7.3+.\n\n## Usage\n\nTo define a mix-in object, add the ```[GenerateMixin]``` attribute to the selected class.\n\n### Defining mix-in objects\n\n```csharp\nnamespace Examples\n{\n    [Minerals.AutoMixins.GenerateMixin]\n    public class ExampleMixin1\n    {\n        public float Property1 { get; set; } = 0.5f;\n\n        private int _field1 = 0;\n\n        private void Method1()\n        {\n            Console.WriteLine(\"Test1\");\n        }\n    }\n\n    [Minerals.AutoMixins.GenerateMixin]\n    public class ExampleMixin2\n    {\n        public string PropertyText1 { get; set; } = \"Test2\";\n    }\n}\n```\n\n### Using mix-in objects\n\nTo use the selected mix-in object, add the ```[AddMixin(typeof(ExampleMixin1))]``` attribute to the selected class. The class implementing the **AddMixin** attribute must have the **partial** modifier to work properly.\n\n```csharp\nnamespace Examples\n{\n    [Minerals.AutoMixins.AddMixin(typeof(ExampleMixin1))]\n    public partial class ExampleClass\n    {\n        public int MyProperty { get; set; } = 3;\n    }\n}\n```\n\nThe code above will generate an ```ExampleClass.g.cs``` file with a partial class ```ExampleClass```.\n\n```csharp\nnamespace Examples\n{\n    [global::System.Diagnostics.DebuggerNonUserCode]\n    [global::System.Runtime.CompilerServices.CompilerGenerated]\n    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]\n    public partial class ExampleClass\n    {\n        // MixinType: ExampleMixin1\n        public float Property1 { get; set; } = 0.5f;\n        private int _field1 = 0;\n        private void Method1()\n        {\n            Console.WriteLine(\"Test1\");\n        }\n    }\n}\n```\n\n### Multiple mix-ins\n\nThis package allows you to add multiple mix-in objects to a single class through attribute arguments ```[AddMixin(typeof(ExampleMixin1), typeof(ExampleMixin2))]```.\n\n```csharp\nnamespace Examples\n{\n    [Minerals.AutoMixins.AddMixin(typeof(ExampleMixin1), typeof(ExampleMixin2))]\n    public partial class ExampleClass\n    {\n        public int MyProperty { get; set; } = 3;\n\n        public void MyMethod()\n        {\n\n        }\n    }\n}\n```\n\nThe code above will generate an ```ExampleClass.g.cs``` file with a partial class ```ExampleClass```.\n\n```csharp\nnamespace Examples\n{\n    [global::System.Diagnostics.DebuggerNonUserCode]\n    [global::System.Runtime.CompilerServices.CompilerGenerated]\n    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]\n    public partial class ExampleClass\n    {\n        // MixinType: ExampleMixin1\n        public float Property1 { get; set; } = 0.5f;\n        private int _field1 = 0;\n        private void Method1()\n        {\n            Console.WriteLine(\"Test1\");\n        }\n        // MixinType: ExampleMixin2\n        public string PropertyText1 { get; set; } = \"Test2\";\n        public string MethodText1()\n        {\n            return PropertyText1;\n        }\n    }\n}\n```\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [branches on this repository](https://github.com/SzymonHalucha/Minerals.AutoMixins/branches).\n\n## Authors\n\n- **Szymon Hałucha** - Maintainer\n\nSee also the list of [contributors](https://github.com/SzymonHalucha/Minerals.AutoMixins/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSzymonHalucha%2FMinerals.AutoMixins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSzymonHalucha%2FMinerals.AutoMixins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSzymonHalucha%2FMinerals.AutoMixins/lists"}