(Ab)using the compiler to generate not just C# code
Since you can basically do anything within the code generator, you could go and generate anything else. One of the things we use it for in my day-to-day work is to generate TypeScript files from our C# code. This is super useful and we save a lot of time and gain consistency in the TypeScript, in line with the REST APIs in C#.
Let’s go and do something that doesn’t end up in a C# file. Based on the Fundamentals project in the GitHub repository and what you have built so far in the book, you should have a namespace called Fundamentals.Compliance.GDPR and an attribute called PersonalIdentifiableInformation, which was introduced in Chapter 5, Leveraging Attributes.
This attribute is great for marking types that collect Personally Identifiable Information (PII) as well as the reason for collecting PII. In Chapter 5, Leveraging Attributes, we used it at runtime to create a runtime report. What we could instead do is...