Creative Commons Zero v1.0 Universal

项目介绍

amis92/csharp-source-generators 是一个托管在 GitHub 上的开源项目,采用 Creative Commons Zero v1.0 Universal 许可证,目前获得 2.4k 个 Star、225 次 Fork。

仓库全名
amis92/csharp-source-generators
开源许可证
Creative Commons Zero v1.0 Universal
Star 数
2.4k
Fork 数
225
未关闭 Issue
2

README 摘要

C# Source Generators Documentation and samples Source Generators Meta - libs and generators for other generators Tips & Tricks Articles Videos Demo, PoC and excercise projects Projects using custom Source Generators "internally" A list of C# Source Generators (not necessarily awesome), because I haven't found a good list yet. C# Source Generators is a Roslyn compiler feature introduced in C#9/.NET 5. It lets C#…

完整内容见 GitHub 原始 README 或本页 。

常见问题

csharp-source-generators 可以免费商用吗?

仓库标注的许可证为 Creative Commons Zero v1.0 Universal,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 csharp-source-generators 的源码?

可以直接克隆仓库:git clone https://github.com/amis92/csharp-source-generators.git,默认分支为 main;安装与运行步骤见仓库 README。

csharp-source-generators 最近还在维护吗?

仓库最近一次更新为 9月3日,当前有 2 个未关闭 Issue;Star 数为 2.4k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A list of C# Source Generators (not necessarily awesome) and associated resources: articles, talks, demos.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
2942
价值分
1524
活跃状态
活跃

README

C# Source Generators


A list of C# Source Generators (not necessarily awesome), because I haven’t found a good list yet.

C# Source Generators is a Roslyn compiler feature introduced in C#9/.NET 5. It lets C# developers inspect user code and generate new C# source files that can be added to a compilation.

Add GitHub topic csharp-sourcegenerator to your generator repo - let’s get it started!

Documentation and samples

Source Generators

Categories

Dependency Injection (IoC Container)

  • AutoCtor - stars last commit AutoCtor is a Roslyn Source Generator that will automatically create a constructor for your class for use with constructor Dependency Injection.
  • AutoRegisterInject - stars last commit Automatically generate Microsoft Dependency Injection ServiceCollection registrations for your classes from attributes.
  • CircleDI -stars last commit The world only full-power circular Service Provider. It can resolve circular dependencies, has compile time safety and optimal performance.
  • DependencyInjection.SourceGenerators stars last commit This project is a C# source generator designed to simplify and automate the registration of dependencies in Microsoft’s Dependency Injection service collection. By using this package, developers can enhance the clarity and efficiency of their code by reducing the need for manual service registration.
  • DependencyManagement - stars last commit The Dependency Management is a very fast dependency injection and components container, with many interesting features, and without reflection.
  • GrpcInjection -stars last commit - GrpcInjection is a tool that allow you to inject Services and Interceptor in time of compilation inside of GRPC Projects using C# source generator.
  • Immediate.Injections - stars last commit - Source generated dependency injection registrations
  • Injectio - stars last commit - Source generator that helps register discovered services in the dependency injection container
  • Jab -stars last commit - Compile Time Dependency Injection
  • lambdajection -stars last commit Framework for building AWS Lambdas using dependency injection and aspect-oriented programming.
  • MrMeeseeks.DIE - stars last commit An unambigous, convenient, flexible and feature rich compile time dependency injection container.
  • Pure.DI - stars last commit - dependency injection for .NET without any IoC/DI containers, frameworks, dependencies, and thus without any performance impact and side-effects.
  • ServiceScan.SourceGenerator - stars last commit Type scanning source generator for Microsoft.Extensions.DependencyInjection services registrations inspired by Scrutor.
  • SourceDepend - stars last commit Simply tag members with a [Dependency] attribute and those will be added to the constructor, saving you from manual coding the constructor.
  • SourceInject -stars last commit A source generator that allow you to generate your services for dependencies injection during compile time.
  • StrongInject -stars last commit - compile time dependency injection for .NET.
  • Thunderboltloc - stars last commit One of the very first IoC frameworks for .Net that has no reflection.

Console / CLI

  • AutoSpectre - stars last commit Generates a service for prompting and populating a class using the Spectre.Console library
  • ConsoleAppFramework - stars last commit - Zero Dependency, Zero Overhead, Zero Reflection, Zero Allocation, AOT Safe CLI Framework powered by C# Source Generator.
  • docopt.net - stars last commit generates C# source code that parses command-line arguments into a strong-typed arguments class (also generated), given just the POSIX-style usage in plain text as part of the CLI. In other words, write the help message for your program and get the entire parser generated for free!
  • Figgle - stars last commit - Generate ASCII banner text at compile time (or run time) using figlet fonts.

Mappers

  • AutoDto -stars last commit - A source generator that generates DTO models from BL to avoid same BL and DTO models
  • Facet -stars last commit A source generator that instantly scaffolds DTOs, ViewModels and typed LINQ projections.
  • Flattening - stars last commit - C# source generator for generating flattened classes from complex domain classes.
  • GraphQL.Tools -stars last commit - A GraphQL to C# compiler (code-generator) which turns your GraphQL schema into a set of C# classes, interfaces, and enums.
  • Mapperly -stars last commit - A source generator for generating object mappings. Inspired by MapStruct.
  • MappingCloningExtensions - stars last commit Generates extensions of objects for mapping and cloning using either attributes or fluent style. Also, supports deep copying and specfiying whether it can do a deep copy and the possibility of doing so safely.
  • Mapster -stars last commit - A fast, fun and performant object to object Mapper. Has better performance and is more memorry efficient than Automapper. Besides code generation, supports also Fluent API.
  • MapTo -stars last commit - A convention based object to object mapper similar to Automapper.
  • NextGenMapper - stars last commit Easy-to-use mapper without configuration.
  • SourceMapper - stars last commit - generates Mappers code based on attributes used on interfaces or abstract classes. It is inspired by Java MapStruct
  • SourceMapper -stars last commit A source generator that creates extension methods for cloning and mapping.
  • Facet -stars last commit A source generator that instantly scaffolds DTOs, ViewModels and typed LINQ projections.
  • FastCloner -stars last commit A source generator for deep cloning of objects with automatic reflection-based fallback for types that cannot be cloned ahead of time.

Communication

  • CoreWCF -stars last commit CoreWCF provides support of WCF server side code on .NET Core / .NET6. CoreWCF allows users to inject services into OperationContract implementation using a source generator to provide an OperationContract implementation that fits the expected ServiceContract. The supplied implementation fetch services from the DI container the same way the [FromServices] attribute works in ASP.NET core MVC Controllers. The source generator supports both a dedicated [Injected] attribute and the ASP.NET Core MVC [FromServices] attribute.
  • Imp.NET -stars last commit - a fast, high-level, object-oriented C# networking library that supports the invocation of remote methods through proxy interface objects.
  • IoTHubClientGenerator - stars last commit Build a C# Azure IoT Device client program in seconds!

Graphics / Drawing

  • ComputeSharp -stars last commit A .NET library to run C# code in parallel on the GPU through DX12 and dynamically generated HLSL compute shaders, which are transpiled from C# and precompiled at build-time using source generators.
  • Svg to C# Source Generators -stars last commit SVGC compiles SVG drawing markup to C# using SkiaSharp as rendering engine. SVGC can be also used as codegen for upcoming C# 9 Source Generator feature.

Enums

  • BetterEnums - stars last commit C# Enums with values and better performance as a source generator
  • Credfeto.Enumeration.Source.Generation -stars last commit Enum to text generator for enums - generates strongly typed enums for all enums in the assembly, and using EnumText attribute for third party enums. Also includes an analyzer to ensure that all enum usages use the .GetName extension method rather than .ToString.
  • Enum.Source.Generator - stars last commit A C# source generator to create an enumeration (enum) class from an enum type. With this package, you can work on enums very, very fast without using reflection.
  • EnumClass - stars last_commit Generate Kotlin’s enum class from C# enum with additional features like Switch function (instead of switch statement). It also contains support libraries like generator for JsonConverter for generated classes
  • EnumerationClassGenerator -stars last commit - A C# source generator to create an enumeration class from an enum type.
  • EnumFastToStringDotNet -stars last commit - Automatically generates enum extension methods that implement a switch expression based ToString method.
  • EnumUtilities - stars last commit - A source generator that creates extension methods and utilities for enums with flags support, atomic operations (InterlockedAdd, InterlockedOr, etc.), and JSON converter generation.
  • EnumUtilitiesGenerator -stars last commit - A source generator to generate compile-time mapping of enums and description attributes.
  • FastEnumGenerator - stars last commit An enum like generator where you create a partial class with private enum and it will generate an enum like record struct even including returning the words and a list.
  • JOS.Enumeration - stars last commit Enumeration class powered by source generation
  • NetEscapades.EnumGenerators - stars last commit A source generator for generating fast “reflection” methods for enums
  • RapidEnum - stars last commit - RapidEnum is a Source Generator that provides fast-running enum utilities for C#/.NET. It is faster than the .NET API and achieves zero allocation for all methods.

Functional Programming

Value semantic / New Type Idiom
  • ComparisonOperatorsGenerator - stars last commit A Source Generator package that generates the >, >=, <, <= operators for a partial type (class, struct or record) which implements IComparable<T>.
  • Generator.Equals - stars last commit generates equality and hashing for classes and records, supports a number of strategies for comparing collections and properties.
  • RSCG_UtilityTypes - stars last commit Add Omit and Pick attributes to generate classes from existing class, like in TypeScript.
  • Strongly stars last commit - Easily generate serializable domain value types
  • StronglyTypedId - stars last commit A Rosyln-powered generator for strongly-typed IDs
  • ValueObjectGenerator - stars last commit C# source generator is for ValueObjects (ie.Wrapper classes).
  • Vogen - stars last commit C# source generator and code analyser that generates strongly typed domain identities.
  • WrapperValueObject - stars last commit - for creating simple value objects wrapping primitive types.
Immutability
Discriminated Unions
  • AnyOf - stars last commit The Source Generator creates a AnyOf<First, TSecond, ...> type to handle multiple defined types as input parameters for methods.
  • dotVariant - stars last commit A type-safe and space-efficient sum type for C# (comparable to discriminated unions in C or C++).
  • Dunet - stars last commit A simple source generator for discriminated unions in C#.
  • Funcky Discriminated Unions - stars last commit A source generator that generates Match methods for all your discriminated unions needs. ✨ Can be used with or without the functional programming library Funcky.
  • MatchGenerator -stars last commit Bring exhaustive pattern matching to C# enums and unions with zero boilerplate.
  • N.SourceGenerators.UnionTypes - stars last commit Discriminated union type source generator.
  • Unions - stars last commit for generating meaningful, efficient union types.

Serialization

  • AutoDeconstructable -stars last commit Generator for efficient and automatic flat text serializer/deserializer using Deconstructable aspect in NTP library.
  • Azura -stars last commit Generates binary [de]serializers on Streams at design time.
  • Csv-CSharp - stars last commit - Csv-CSharp is a highly performant CSV (TSV) parser for .NET and Unity. It is designed to parse UTF-8 binaries directly and leverage Source Generators to enable serialization/deserialization between CSV (TSV) and object arrays with zero (or very low) allocation.
  • CSV-Parser-Generator - stars last commit A Parser for CSV with support for uncommon line separators (e.g. Unicode) and instantiation of read-only objects and working nullable handling.
  • GenPack - stars last commit is a library that uses the .NET source generator to automatically generate packets as classes once you define a schema for the packets. It’s easy to use and the results are useful.
  • MemoryPack - stars last commit - Zero encoding extreme performance binary serializer for C# and Unity.
  • MessagePack for C# - stars last commit - Extremely Fast MessagePack Serializer for C#(.NET, .NET Core, Unity, Xamarin). / msgpack.org[C#]
  • ProtobufSourceGenerator -stars last commit - A source generator that generates partial helper classes where member properties are attributed with ProtoMember attribute.
  • protobuf-net - stars last commit - protobuf-net is a contract based serializer for .NET code, that happens to write data in the “protocol buffers” serialization format engineered by Google.
  • SerdeDn (serde-sn) -stars last commit is a port of the popular serde.rs Rust serialization/deserialization library to .NET. Basic cases are fully automated using a C# source generator.
  • SpreadCheetah -stars last commit Create Excel files with a C# Source Generator for generating the rows.
  • StackXML -stars last commit Stack based zero-allocation XML serializer and deserializer.
  • StructPacker -stars last commit binary serializer that auto-generates C# serialization code to achieve peak runtime performance and efficiency.
  • Tinyhand -stars last commit - Tiny and simple data format/serializer using a source generator.
  • VYaml - stars last commit - VYaml is a pure C# YAML 1.2 implementation, which is extra fast, low memory footprint with focued on .NET and Unity.
Json
  • GeneratedJsonConverters -stars last commit - generate json converters for polymorph contracts and string based enum serialization.
  • JsonByExampleGenerator -stars last commit - generate classes based on example json files in your project.
  • JsonDeserializeResourceSourceGenerator - stars last commit Instead of having to do embedded resource, can instead have json as additional file and it will produce a c# string and will deserialize to a type specified.
  • JsonPolymorphicGenerator - stars last commit - Source Code Generator for System.Text.Json JsonDerivedType attributes on polymorphic classes
  • JsonSerializerContextGenerator - stars last commit A source generator that produces nearly the same code as system.json.text but easier to use because you only have to put an attribute for a model class you want to produce for. Also, produces a method to register to make it easy to use that source generator when serializing/deserializing json.
  • JsonSrcGen -stars last commit - compile time JSON serializer generation.
  • TeuJson - stars last commit A Reflection-less and Lightweight Json Library using source generator.

Caching

Validation

  • EasyValidate -stars last commit - High-performance, type-safe .NET source generator that uses attributes to automatically generate validation for properties, fields, and method parameters. Easy Validate supports async validation, integrates with dependency injection, and includes rich analyzers and code fixers for a seamless developer experience.
  • Immediate.Validations - stars last commit - Source generated validations for easy integration with Immediate.Handlers
  • Validly -stars last commit - A performant, zero-allocation, and highly customizable validation library that generates validation logic based on attributes, with usage similar to DataAnnotations.
  • ValidationModules -stars last commit - High-performance validation library that uses attributes or fluent style validation. Built-in support for dependency injection, localization, and a plethora of analyzers, combine to make a great development experience.

Localization

  • kli.Localize - stars last commit - localize strings from json files via source code generation
  • MrMeeseeks.ResXToViewModelGenerator - stars last commit Takes ResX files and generates localization ViewModels for a more convenient usage of localization in MVVM projects.
  • ResXGenerator -stars last commit Generates strongly-typed resource classes for looking up localized strings.

Testing

  • Buildenator -stars last commit Generate data builder classes for testing purposes (and not only) for your entities. Autofixture + Moq extensions.
  • FluentAssertions.Eventual - stars last commit - Generates a specialized waiting wrapper for FluentAssertions assertions, offering a syntax similar to plain FluentAssertions.
  • ScenarioTests -stars last commit Test your code like you would write a notebook. Simply and effective
Mocking
  • Forged - stars last commit A fake data generation library that respects and enforces required properties.
  • GRPC-Mock-Server -stars last commit - A source generator for stubbing GRPC services.
  • InterfaceGenerator - stars last commit - Auto generate interface definition by implementation, for when you need an abstraction for the sake of mocking.
  • KnockOff - stars last commit Source-generated mocking library with a hybrid stub+mock design. Stubs are real classes you define once and reuse across your test project, with full mock capabilities (Return, Verify, When chains) built in.
  • MockableStaticGenerator - stars last commit A C# source generator to make an interface and a class wrapper to test static/extension methods.
  • MockGen - stars last commit A C# mocking library based on source generators.
  • MockSourceGenerator - stars last commit A C# mocking library that generates mocks at compile-time using a source generator.
  • ProxyInterfaceGenerator -stars last commit generate an interface and a Proxy class for classes. This makes it possible to wrap external classes which do not have an interface, in a Proxy class which makes it easier to Mock and use DI.
  • Rocks - stars last commit A mocking library based on the Compiler APIs (Roslyn + Mocks).

Patterns

  • ActorSrcGen - stars last commit Generates boilerplate to turn simple C# classes into TPL Dataflow compatible pipelines with robust and performant asynchronous and concurrent code.
  • InlineComposition -stars last commit A source generator that merges the content of other classes into one class. A simple workaround for struct inheritance or multiple inheritance.
  • JinShil.MixinSourceGenerator - stars last commit A simple, but powerful source generator that implements the mixin design pattern by copying members—along with their attributes and XML documentation comments—verbatim from one or more source classes/structs into anaother, forming a composition of said classes/structs.
  • Lombok.NET - stars last commit Generates boilerplate code and common code patterns. As the name suggests, it is the .NET version of Java’s Lombok.
  • Minerals.AutoMixins - stars last commit Package for automatic mixin design pattern generation using an incremental source generator.
  • Minerals.AutoCQRS - stars last commit NuGet package that provides interfaces for implementing the CQRS pattern (Commands, Queries, and Pipelines) along with automatic dependency injection and no MediatR package overhead.
Mediator
  • DumplingsDevs.Pipelines - stars last commit The most flexible mediation implementation in the .NET ecosystem with your own types.
  • Foundatio Mediator -stars last commit - Blazingly fast, convention-based C# mediator powered by source generators and interceptors.
  • Immediate.Handlers -stars last commit The fastest source generator implementation of the Mediator pattern in .NET, without using a central mediator instance.
  • Mediator -stars last commit - a high performance implementation of Mediator pattern in .NET using source generators.
  • MediatR controllers generator -stars last commit This generator generates controllers and their methods based on your MediatR requests.
Command
  • Plastic -stars last commit This project provides encapsulation of things like Domain, Application Rules, Business Rules or Business Logic in Application.
Builder
Proxy
  • avatar -stars last commit A modern compile-time generated interception/proxy library.
  • DudNet - stars last commit A C# source generator for implementing a proxy pattern.
Visitor
  • MrMeeseeks.Visitor - stars last commit Generates the boilerplate code for applications of the Visitor pattern.
  • Visitor.NET - stars last commit First-ever acyclic generic extensible typesafe implementation of Visitor pattern for .NET without any usage of dynamic cast. Implementation powered by Source Generators
Adapter
Fluent API
  • SuperFluid - stars last commit Generates the interfaces to represent a fluent API with grammar

Domain Driven Design (DDD)

  • AltaSoft.DomainPrimitives - stars last commit - A C# toolkit purposefully designed to accelerate the development of domain-specific primitives within your applications. This streamlined solution empowers developers to efficiently encapsulate fundamental domain logic. Through this toolkit, you’ll significantly reduce code complexity while improving the maintainability of your project.
  • Architect.DomainModeling - stars last commit A complete Domain-Driven Design (DDD) toolset for implementing domain models, including base types and source generators for ValueObjects, WrapperValueObjects, Entities, and Identities.
  • Minerals.AutoDomain - stars last commit This package provides a fast method of defining domain layer components with their specific implementation, such as aggregates, entities and domain events. Package has built-in strongly typed IDs.

Metaprogramming

  • GenerateHelperLibraries - stars last commit A source generator where you can send any code to the client without having to do as a string. Helper for custom classes a client has to override in order to have additional features for source generators. Intended to be used from another source generator.
  • Gobie -stars last commit - Allows developers define and use custom source generation without writing any generator code themselves or learning the Roslyn APIs. Instead, devs define the generator they want, in C#, and can then use that generator throughout their project.
  • Matryoshki - stars last commit Metaprogramming framework based on C# source generators. It allows you to define behaviours with adornments and generate decorators for arbitrary types.
  • SourceGeneratorQuery - stars last commit - C# SourceGenerator helper which helps you query your files, and adds LINQ support.
  • comptime - stars last commit - Comptime brings meta-programming capabilities to C#, enabling compile-time code generation and evaluation.

Webprogramming

README 内容过长,已截取前 64 KB。完整内容请前往 GitHub 仓库查看。

评论

暂无评论