Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Metaprogramming in C#

You're reading from   Metaprogramming in C# Automate your .NET development and simplify overcomplicated code

Arrow left icon
Product type Paperback
Published in Jun 2023
Publisher Packt
ISBN-13 9781837635429
Length 352 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Einar Ingerbrigsten Einar Ingerbrigsten
Author Profile Icon Einar Ingerbrigsten
Einar Ingerbrigsten
Arrow right icon
View More author details
Toc

Table of Contents (25) Chapters Close

Preface 1. Part 1:Why Metaprogramming?
2. Chapter 1: How Can Metaprogramming Benefit You? FREE CHAPTER 3. Chapter 2: Metaprogramming Concepts 4. Chapter 3: Demystifying through Existing Real-World Examples 5. Part 2:Leveraging the Runtime
6. Chapter 4: Reasoning about Types Using Reflection 7. Chapter 5: Leveraging Attributes 8. Chapter 6: Dynamic Proxy Generation 9. Chapter 7: Reasoning about Expressions 10. Chapter 8: Building and Executing Expressions 11. Chapter 9: Taking Advantage of the Dynamic Language Runtime 12. Part 3:Increasing Productivity, Consistency, and Quality
13. Chapter 10: Convention over Configuration 14. Chapter 11: Applying the Open-Closed Principle 15. Chapter 12: Go Beyond Inheritance 16. Chapter 13: Applying Cross-Cutting Concerns 17. Chapter 14: Aspect-Oriented Programming 18. Part 4:Compiler Magic Using Roslyn
19. Chapter 15: Roslyn Compiler Extensions 20. Chapter 16: Generating Code 21. Chapter 17: Static Code Analysis 22. Chapter 18: Caveats and Final Words 23. Index 24. Other Books You May Enjoy

What this book covers

Chapter 1, How Can Metaprogramming Benefit You?, dives into what metaprogramming is and how it can improve developers’ day-to-day work. It gives some concrete basic examples to explain its capabilities.

Chapter 2, Metaprogramming Concepts, provides explanations of the differences between implicit and explicit metadata through concrete examples. In addition, it gives an insight into how the .NET runtime works.

Chapter 3, Demystifying through Existing Real-World Examples, shows how Microsoft, as an example, leverages metaprogramming and how you probably already use it.

Chapter 4, Reasoning about Types Using Reflection, provides an overview of how powerful the .NET runtime reflection is and how its implicit metadata can be leveraged.

Chapter 5, Leveraging Attributes, introduces leveraging C# attributes as an explicit metaprogramming technique and how it can be used, giving real-world applicable examples.

Chapter 6, Dynamic Proxy Generation, introduces code that generates code, at runtime. A powerful concept that can really boost your developers’ productivity if used wisely.

Chapter 7, Reasoning about Expressions, provides an introduction to C# and .NET expression trees, how they represent a different aspect of metadata, and how they can be reasoned about and unpacked in your code.

Chapter 8, Building and Executing Expressions, provides an introduction to how you can build your own expressions at runtime and how these can be executed – an alternative technique to generating code.

Chapter 9, Taking Advantage of the Dynamic Language Runtime, covers what the Dynamic Language Runtime is and how it can be used to dynamically generate code – yet another alternative for your code is to create code.

Chapter 10, Convention over Configuration, unravels the superpower of conventions – code that repeats the patterns you probably already have, enabling your developers to become more productive and your code base to become more consistent.

Chapter 11, Applying the Open-Closed Principle, provides a dive into how you can create code bases that are open to extension but closed for modification – a powerful principle for maintainable software, using metaprogramming as an angle into it.

Chapter 12, Go Beyond Inheritance, provides another level on top of regular conventions, giving developers an opportunity to not just be limited by what the programming language offers, aiming for readability and maintainability.

Chapter 13, Applying Cross-Cutting Concerns, unlocks the concept of applying code consistently across an entire code base without having to revert to manual recipes.

Chapter 14, Aspect-Oriented Programming, provides details on the formalization of aspect-oriented programming and how this can help you provide cross-cutting concerns as a more formal technique.

Chapter 15, Roslyn Compiler Extensions, details the basics of what the .NET compiler SDK offers and how to get started with it, serving as the basis for the following chapters.

Chapter 16, Generating Code, provides an introduction to how you can generate code using code at the compiler level before you enter runtime – yet another great way to improve your developers’ productivity and provide consistency in your code base.

Chapter 17, Static Code Analysis, provides an introduction to how you can build your own rules that perform analysis on any code being added to your project, helping you create consistent, uniform, and more maintainable code.

Chapter 18, Caveats and Final Words, looks into what the book has covered, what benefits there are, and what caveats there are. As with anything, you have to strike the right balance and know what to use when.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime