Type less, generate more
What else can we generate? There is an unpredictably large number of things that can be generated. All of them will probably be generated in the future, which means we will have time to focus more on the important things in our applications.
There are already some awesome projects using generators internally. You may know System.Text.Json
. This package allows us to convert an object into JSON and back. The package itself uses a generator to speed up mapping.
Another package that uses a source generator for mapping is Mapster
. This NuGet package is an alternative to AutoMapper
and allows us to map objects between each other. Mapping using Mapster
is one of the fastest options available because the mapping is not generated at runtime; the mapping methods are generated at design time.
Source generators can be used to generate validators, mappers, enums, and many more classes and methods. Only the future will show us what generators and the people using...