Experimental zero code compile time DTO generator and mapper using Source Generators in C#
License: MIT License
C# 100.00%
dtogenerator's Introduction
DTOGenerator
Experimental zero code compile time DTO generator and mapper using Source Generators in C#.
Attributes
Attribute
Description
Notes
GenerateDto
Add to class to generate DTO.
If DTO name isn't supplied, by default DTOGenerator will create one called "classNameDTO". DTOGenerator can create unlimited amount of DTOs from the same class. Refer to example below.
ExcludeProperty
Add to exclude property in DTO.
You can supply a name of a DTO to only exclude in specific ones, else it will be excluded in all DTOs.
UseExistingDto
Add to use an existing DTO for an object that is nested in another DTO.
You can supply a specific DTO to use based off of.
This will create two DTOs "StationDTO" and "StationWithNoNameDTO". "Name" will be excluded in "StationWithNoNameDTO" and "Level" will be excluded in all.
This will create two DTOs "WeatherForecastDTO" and "TestingWeather". "TemperatureF" will be excluded in all DTOs. "Summary" will be excluded in the "TestingWeather" DTO. "StationWithNoNameDTO" will be used in "TestingWeather" but in "WeatherForecastDTO" it will use the default "StationDTO".