{"id":24629554,"url":"https://github.com/sharpjs/mixer","last_synced_at":"2026-05-20T07:39:49.362Z","repository":{"id":154543284,"uuid":"612804176","full_name":"sharpjs/Mixer","owner":"sharpjs","description":"Mixin support for C#","archived":false,"fork":false,"pushed_at":"2023-05-20T18:51:13.000Z","size":244,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-18T22:53:31.691Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sharpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-03-12T02:40:11.000Z","updated_at":"2024-05-18T03:07:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee4a393f-abba-4f22-83ba-e783caab73dd","html_url":"https://github.com/sharpjs/Mixer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/sharpjs/Mixer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FMixer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FMixer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FMixer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FMixer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharpjs","download_url":"https://codeload.github.com/sharpjs/Mixer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FMixer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33250375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-20T04:48:54.280Z","status":"ssl_error","status_checked_at":"2026-05-20T04:48:10.851Z","response_time":356,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-01-25T06:13:14.397Z","updated_at":"2026-05-20T07:39:49.347Z","avatar_url":"https://github.com/sharpjs.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mixer\n\n[![Build](https://github.com/sharpjs/Mixer/workflows/Build/badge.svg)](https://github.com/sharpjs/Mixer/actions)\n[![Build](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/sharpjs/Mixer/actions)\n[![NuGet](https://img.shields.io/nuget/v/Mixer.svg)](https://www.nuget.org/packages/Mixer)\n[![NuGet](https://img.shields.io/nuget/dt/Mixer.svg)](https://www.nuget.org/packages/Mixer)\n\n[Mixin](https://en.wikipedia.org/wiki/Mixin) support for C#.\nWhen you can't inherit, include!\n\nMixer provides a smart `[Include]` attribute that copies the content of one\ntype into another type.  This enables you to 'inherit' from additional types\nbeyond the single base class that C# allows.\n\nFor example, this code:\n\n```csharp\n[Include\u003cPet\u003e]\npublic partial class Dog : Mammal\n{\n    public void Bark() { ... }\n}\n\n[Mixin]\ninternal class Pet : IPet\n{\n    public string Name { get; set; }\n}\n```\n\ncompiles as if you had written:\n\n```csharp\npublic class Dog : Mammal, IPet\n{\n    public void Bark() { ... }\n\n    public string Name { get; set; }\n}\n```\n\nSome facts about this example:\n\n- `Dog` inherits the members of its base class, `Mammal`.\n- An instance of `Dog` can be cast to `Mammal`.\n- Through Mixer, `Dog` also _includes_ the members, interfaces, and attributes of `Pet`.\n- An instance of `Dog` _cannot_ be cast to `Pet`.  C# allows only a single base class.\n- An instance of `Dog` _can_ be cast to `IPet`.\n\nMixer is implemented as a [Roslyn incremental generator](https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.md)\nfor minimal impact to build times.  For each inclusion, Mixer generates a\npartial type with the name of the target type and containing the members, base\ntypes, and attributes of the mixin.\n\n## Installation\n\nInstall [this NuGet Package](https://www.nuget.org/packages/Mixer) in your project.\n\n## Usage\n\nTo make a class, struct, or record become includable (i.e. a *mixin*), add\nthe `[Mixin]` attribute to it.\n\n```\nusing Mixer;\n\n[Mixin]\ninternal class MyMixin { ... }\n```\n\nTo include the mixin into some other class, struct, or record (i.e. a target\ntype), make the target type `partial` and add the `[Include]` attribute to it.\nMixer provides both generic and non-generic versions of this attribute.\n\n```csharp\nusing Mixer;\n\n// C# 11 and later:\n\n[Include\u003cMyMixin\u003e]\npartial class MyTargetType { ... }\n\n// Any verison of C#:\n\n[Include(typeof(MyMixin))]\npartial class MyTargetType { ... }\n```\n\nThat's it!\n\n## Building from Source\n\nIf you have Visual Studio 2022, just open `Mixer.sln` and build as you would\nany other solution.\n\nOr from PowerShell 7:\n\n```powershell\n# The default: build and run tests\n.\\Make.ps1 [-Test] [-Configuration \u003cString\u003e]\n\n# Just build; don't run tests\n.\\Make.ps1 -Build [-Configuration \u003cString\u003e]\n\n# Build and run tests with coverage\n.\\Make.ps1 -Coverage [-Configuration \u003cString\u003e]\n```\n\n## Advanced Topics\n\n### How do I see the generated code?\n\nAdd the following to the project file.\n\n```xml\n  \u003cPropertyGroup\u003e\n    \u003cEmitCompilerGeneratedFiles\u003etrue\u003c/EmitCompilerGeneratedFiles\u003e\n  \u003c/PropertyGroup\u003e\n```\n\nBuilds will drop the generated files into the following folder:\n\n`obj\\{config}\\{target}\\generated\\Mixer.Generator\\Mixer.MixinGenerator\\`\n\nTo see the generated files in Visual Studio's solution explorer:\n\n```xml\n  \u003cItemGroup Condition=\"'$(EmitCompilerGeneratedFiles)' == 'true'\"\u003e\n    \u003cGeneratedFile Include=\"$(IntermediateOutputPath)generated\\Mixer.Generator\\Mixer.MixinGenerator\\*.cs\" /\u003e\n    \u003cNone Include=\"@(GeneratedFile)\" Link=\"Generated\\%(Filename)%(Extension)\" /\u003e\n    \u003cFileWrites Include=\"@(GeneratedFile)\" /\u003e\n  \u003c/ItemGroup\u003e\n```\n\n\u003c!--\n  Copyright 2023 Subatomix Research Inc.\n  SPDX-License-Identifier: ISC\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Fmixer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharpjs%2Fmixer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Fmixer/lists"}