Source generators and a boilerplate code

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • SourceMapper

    Mappings code generator based on attributes (by alekshura)

  • More about code, examples and contributing you can find on SourceMapper GitHub.

  • SourceConfig

    Generates configuration objects in build-time based on *.json config files

  • Source code and more, of course, on SourceConfig GitHub.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • swagger-ui

    Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

  • There are two approaches when implemening Web API: code first, that most of developers prefer: to create Web API controllers, DTO’s, to add Swagger UI and that’s all!; and API first, when API needs to be designed or discussed and only after that we start to implement it. In distributed systems with a various technologies and consumers of our API it is good to have language agnostic tools to agree and share API between the consumers. Open API Specification has been created for that:

  • NSwag

    The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.

  • StoreControllerBase class is generated as (underhood it uses NSwag CSharpControllerGenerator to generate abstract controllers):

  • MapStruct

    An annotation processor for generating type-safe bean mappers

  • During my work on different cloud-native applications with a various tech stacks I’ve paid attention to Java’s widely used mapping library MapStruct, where developers define mappings using Java annotations (in C# attributes). The SourceMapper package uses Source Generators and generates objects mappings based on C# attributes actually during coding. Of course, there is widely used .NET Mapper library AutoMapper, but the main difference between tham, that developer can see (and control) mappings in generated code. The package can be installed using Nuget Package Manager:

  • SourceApi

    API first Open API code generator based on json or yaml definitions.

  • Some configuration properties also added to the package: you can define the namespace of your base controllers, or you can generate only DTO’s in a case when you are the consumer of some REST API. Source code and documentation can be found on SourceApi GitHub.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts