.NET Development Using the Compiler API
Abstract
Most developers I know typically view coding as a means to an end. That is, they write the code to satisfy the requirements set forth by the business. The code is interpreted or compiled, but either way, the final result is machine code that executes and (hopefully) does the right thing. However, there’s more to software development than just that. I’m not talking about process or patterns per se, what I’m getting at is for developers to view their code in a more analytical way. Throughout my career, I’ve run into numerous cases in which I would’ve loved to have the ability to analyze my code so I could find errors quickly. I’ve also wanted to be able to extend and augment languages in certain ways so I didn’t have to write the same code over and over again. The primary language that I’ve used throughout my career has been C#, and although C# is a fine language to develop in, it seemed to lack these dynamic, analytical capabilities. That’s no longer the case. Microsoft has provided public, open-source compon nts in its Compiler API that allows developers to create analyzers that will help them detect problematic issues. This API also empowers developers to build code at runtime to create amazing, dynamic applications and libraries. Because all of this code is open source, it’s available to read and contribute to. Enabling .NET developers to shape and mold the future of the .NET compilation system is a wonderful thing to behold, and it’s exciting to see the development community embrace this model. I wrote this book to help you navigate this new open-source API world. In it, I demonstrate how to use the Compiler API to write custom analyzers and refactorings to improve your code base. I show you how to use the Scripting API (part of the Compiler API) to use C# as a scripting language, a feature that was essentially unavailable to C# developers. I also illustrate how to use the Compiler API in innovative ways that go beyond these typical scenarios. My hope is that when you’ve finished this book, you’ll view C# and the ecosystem that supports it in a fundamentally different (and hopefully positive!) way—as language that is open in terms of its implementation and its community involvement.
Collections
- Technology [3030]