This chapter explains how to build your own aspects. If you only want to learn how to use aspects written by others, you can skip this chapter in first reading. However, we suggest you to come back here if you want to understand better the "magic" behind Metalama.
Boilerplate elimination. When you use the code transformation abilities of aspects to generate boilerplate at compile time, you get the following benefits:
- Less code to write. You no longer need to write repetitive code because it is generated by your aspect.
- Clean and readable code. This is even more important. Your source code is cleaner, with fewer lines of code for the same feature. The business logic clearly stands because it is not littered by boilerplate.
- Fewer bugs. Since there is less code, there is also fewer bugs. When there is a bug or change in the pattern, you fix the aspect once and
Code validation. You can use aspects to create custom attributes that validate code. For details and benefits, see Validating Code.
- Code fixes and refactorings. You can use aspects to suggest code fixes and refactorings. For details, see Building IDE Interactions.
In this chapter
This chapter is composed of the following articles:
|T# Template||This article explains how to create dynamic code templates.|
|Transforming Code||This section explains how to create aspects that perform advanced code modifications using the complete API.|
|Reporting and Suppressing Diagnostics||This article explains how to report or suppress errors, warnings and information messages.|
|Building IDE Interactions||This article explains how to create live templates, code fixes and refactorings.|
|Adding Child Aspects||This section explains how an aspect can add other aspects, and how child aspects can know about their parents.|
|Ordering Aspects||This article describes how to order aspect classes so that the order of execution is correct when several aspects are applied to the same declaration.|
|Exposing Configuration||This article explains how an aspect can expose and consume configuration properties or a configuration API.|
|Testing Aspects||This section explains how to test aspects.|
|Debugging Aspects||This article explains how to debug aspects.|