Share E-Book

Tools and Skills for .NET 10, Second Edition (Mark J. Price)(Z-Library)

Author Mark J. Price

c/c++/c#
Language English

Get the career you want with good practices and patterns to design, debug, and test your solutions Are you ready to elevate your .NET development skills and prepare yourself for a thriving career in the industry? Tools and Skills for .NET 10 is your go-to guide that combines powerful tools and career strategies to empower your professional growth. By the end of this book, you'll not only master technical skills but also gain the confidence to apply them effectively. What this Book will help me do Understand and utilize key features of advanced code editors for efficient .NET development. Master debugging and memory analysis techniques to troubleshoot issues effectively. Learn methods to apply cryptography for securing your applications and sensitive data. Optimize the performance of applications through proper testing frameworks and benchmarks. Implement cloud-native solutions and containerized applications using .NET tools. Author(s) Mark J. Price, a seasoned developer and author, leverages his extensive experience in software development to guide readers through mastering .NET technologies. Drawing from years of industry best practices, Mark presents concepts in a practical, easy-to-understand manner to help developers succeed. His approachable style empowers readers to not only learn but also apply knowledge effectively. Who is it for? This book is tailored for professional .NET developers aiming to enhance their skillset, as well as aspiring developers looking to break into the field. If you're an individual ready to embrace modern techniques, optimize your development process, or pursue career advancements in .NET development, this resource is ideal for you.

Format PDF
Size 9.6 MB
13
Views
0
Downloads
0.00
Total Donations
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
Tools and Skills for .NET 10 Second Edition Get the career you want with good practices and patterns to design, debug, and test your solutions Mark J. Price
Page 3
Tools and Skills for .NET 10 Second Edition Copyright © 2026 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Portfolio Director: Ashwin Nair Relationship Lead: Nitin Nainani Project Manager: Ruvika Rao Content Engineer: Hayden Edwards Technical Editor: Arjun Varma Copy Editor: Hayden Edwards Indexer: Manju Arasan Proofreader: Hayden Edwards Production Designer: Ajay Patule Growth Lead: Priyadarshini Sharma First published: July 2024 Second edition: January 2026 Production reference: 1171225 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul’s Square Birmingham B3 1RB, UK. ISBN 978-1-83588-250-4 www.packtpub.com
Page 4
Contributors About the author Mark J. Price is a Microsoft Specialist: Programming in C# and Architecting Microsoft Azure Solutions, with over 20 years of experience. Since 1993, he has passed more than 80 Microsoft programming exams and specializes in preparing others to pass them. Between 2001 and 2003, Mark was employed to write official courseware for Microsoft in Redmond, USA. His team wrote the first training courses for C# while it was still an early alpha version. While with Microsoft, he taught “train-the-trainer” classes to get Microsoft Certified Trainers up-to-speed on C# and .NET. Mark has spent most of his career training a wide variety of students, from 16-year-old apprentices to 70-year-old retirees, with the majority being professional developers. Mark holds a BSc in Computer Science. Thank you to all my readers. Your support means I get to write these books and cele- brate your successes. Special thanks to the readers who give me actionable feedback via my GitHub repository and email, and interact with me and the book communities on Discord. You help make my books even better with every edition.
Page 5
About the reviewer Pavel P. Oleynik has a Ph.D. in Computer Science and is the author of more than 100 scientific papers in various languages. He organized and regularly conducted the International Theoretical and Practical Conference, Object Systems. He has been developing software since 1999 and has held the positions of team leader, technical leader, architect, and CTO in multibillion-dollar holdings. He is a recognized expert in areas such as heavy industry, coal industry, agricultural industry, banking, fintech, healthcare, retail, ERP/MES systems, SCM, ITSM, low-code/no-code systems, and foodtech.
Page 6
Learn more on Discord To join the Discord community for this book – where you can share feedback, ask questions to the author, and learn about new releases – follow this QR code: https://packt.link/TS2e
Page 7
(This page has no text content)
Page 8
Table of Contents Preface xiii Free Benefits with Your Book ................................................................................................. xix Chapter 1: Introducing Tools and Skills for .NET 1 Introducing this book and its contents ...................................................................................... 2 Setting up your development environment ................................................................................ 6 Setting up a database and projects for this book ...................................................................... 15 Making good use of the GitHub repository for this book ........................................................... 52 Where to go for help ............................................................................................................... 53 Using future versions of .NET with this book ........................................................................... 59 Practicing and exploring ........................................................................................................ 61 Summary ............................................................................................................................... 62 Chapter 2: Making the Most of the Tools in Your Code Editor 65 Introducing common tools and features .................................................................................. 66 Tools in Visual Studio .............................................................................................................. 69 Tools in VS Code ..................................................................................................................... 93 Decompiling .NET assemblies ................................................................................................. 97 Custom project and item templates ....................................................................................... 111 Practicing and exploring ...................................................................................................... 118 Summary ............................................................................................................................. 120 Chapter 3: Source Code Management Using Git 123 Introducing source code management .................................................................................. 124 Introducing Git .................................................................................................................... 126 Working with Git .................................................................................................................. 133 Reviewing Git repositories .................................................................................................... 149
Page 9
Table of Contentsviii Managing remote repositories .............................................................................................. 156 Branching and merging ........................................................................................................ 159 Practicing and exploring ...................................................................................................... 166 Summary ............................................................................................................................. 168 Chapter 4: Debugging and Memory Troubleshooting 169 Debugging strategies ............................................................................................................ 169 Interactive debugging with Visual Studio ............................................................................... 173 Understanding stack and heap memory ................................................................................ 186 Tools and skills for memory troubleshooting ......................................................................... 197 Practicing and exploring ...................................................................................................... 202 Summary ............................................................................................................................. 203 Chapter 5: Logging, Tracing, and Metrics for Observability 205 Logging and tracing in .NET .................................................................................................. 206 Building a web service for logging ......................................................................................... 211 Monitoring with metrics in .NET ........................................................................................... 216 Introducing OpenTelemetry .................................................................................................. 224 Practicing and exploring ...................................................................................................... 233 Summary ............................................................................................................................. 234 Chapter 6: Documenting Your Code, APIs, and Services 235 Introducing documentation .................................................................................................. 235 Documenting your source code ............................................................................................. 238 Documenting public APIs in class libraries ............................................................................ 240 Documenting services .......................................................................................................... 261 Documenting visually with Mermaid diagrams ...................................................................... 267 Practicing and exploring ...................................................................................................... 274 Summary ............................................................................................................................. 277 Chapter 7: Observing and Modifying Code Execution Dynamically 279 Working with reflection and attributes .................................................................................. 280 Working with expression trees .............................................................................................. 297 Creating source generators ................................................................................................... 301 Practicing and exploring ...................................................................................................... 306 Summary ............................................................................................................................. 307
Page 10
Table of Contents ix Chapter 8: Protecting Data and Apps Using Cryptography 309 Understanding the vocabulary of protection .......................................................................... 310 Encrypting and decrypting data ............................................................................................ 313 Hashing data ........................................................................................................................ 321 Signing data ......................................................................................................................... 326 Generating random numbers for cryptography ..................................................................... 329 Authenticating and authorizing users .................................................................................... 331 Practicing and exploring ...................................................................................................... 339 Summary ............................................................................................................................. 340 Chapter 9: Multitasking and Concurrency 343 Understanding processes, threads, and tasks ......................................................................... 343 Running tasks asynchronously .............................................................................................. 347 Synchronizing access to shared resources ............................................................................. 363 Understanding async and await ............................................................................................ 372 Practicing and exploring ...................................................................................................... 381 Summary ............................................................................................................................. 382 Chapter 10: Dependency Injection, Containers, and Service Lifetime 385 Introducing dependency injection ........................................................................................ 385 Implementing .NET Generic Host ......................................................................................... 394 Special cases of DI with ASP.NET Core ................................................................................... 406 Practicing and exploring ...................................................................................................... 410 Summary ............................................................................................................................. 411 Chapter 11: Unit Testing and Mocking 413 Introducing all types of testing ............................................................................................. 414 Pros and cons of test-driven development ............................................................................. 419 Unit testing using xUnit ........................................................................................................ 421 Mocking in tests ................................................................................................................... 442 Making fluent assertions in unit testing ................................................................................. 447 Generating fake data with Bogus ........................................................................................... 451 Practicing and exploring ...................................................................................................... 457 Summary ............................................................................................................................. 459
Page 11
Table of Contentsx Chapter 12: Integration and Security Testing 461 Basics of integration testing .................................................................................................. 462 Integration testing with data stores ....................................................................................... 466 Testing services using dev tunnels ........................................................................................ 470 Introducing security testing .................................................................................................. 477 Practicing and exploring ...................................................................................................... 484 Summary ............................................................................................................................. 485 Chapter 13: Benchmarking Performance, Load, and Stress Testing 487 Benchmarking performance ................................................................................................. 488 Using BenchmarkDotNet for benchmarking performance ..................................................... 492 Load and stress testing ......................................................................................................... 503 Bombardier – a fast cross-platform HTTP benchmarking tool ................................................ 506 NBomber – a load testing framework .................................................................................... 516 Practicing and exploring ...................................................................................................... 521 Summary ............................................................................................................................. 523 Chapter 14: Functional and End-to-End Testing of Websites and Services 525 Understanding functional and end-to-end testing .................................................................. 525 Testing web user interfaces using Playwright ........................................................................ 527 Interacting with a web user interface .................................................................................... 540 Generating tests with the Playwright Inspector ...................................................................... 545 Testing web services using xUnit ........................................................................................... 549 Practicing and exploring ...................................................................................................... 553 Summary ............................................................................................................................. 554 Chapter 15: Containerization Using Docker 555 Introducing containerization ................................................................................................ 555 Understanding Docker concepts ........................................................................................... 561 Managing containers with Docker ......................................................................................... 570 Working with Testcontainers ................................................................................................ 588 Practicing and exploring ...................................................................................................... 590 Summary ............................................................................................................................. 591
Page 12
Table of Contents xi Chapter 16: Cloud-Native Development Using Aspire 593 Introducing Aspire ............................................................................................................... 594 Exploring the Aspire starter template .................................................................................... 603 Diving deeper into Aspire ..................................................................................................... 609 Aspire for new and existing solutions .................................................................................... 622 Practicing and exploring ...................................................................................................... 639 Summary ............................................................................................................................. 641 Chapter 17: Design Patterns and Principles 643 SOLID principles .................................................................................................................. 644 Design patterns .................................................................................................................... 660 Design principles ................................................................................................................. 671 Algorithms and data structures ............................................................................................. 679 Practicing and exploring ...................................................................................................... 682 Summary ............................................................................................................................. 683 Chapter 18: Software and Solution Architecture Foundations 685 Introducing software and solution architecture ..................................................................... 686 Uncle Bob’s Clean Architecture ............................................................................................. 696 Diagramming design using Mermaid ..................................................................................... 700 Practicing and exploring ...................................................................................................... 710 Summary ............................................................................................................................. 712 Chapter 19: Your Career, Teamwork, and Interviews 713 Working on a development team ........................................................................................... 713 Applying for a job ................................................................................................................. 723 Sample interview questions .................................................................................................. 743 Practicing and exploring ...................................................................................................... 756 Summary ............................................................................................................................. 757 Chapter 20: Epilogue 759 Next steps on your .NET learning journey .............................................................................. 759 Companion books to continue your learning journey ............................................................. 759 Other Packt .NET books to take your learning further ............................................................ 760 Good luck! ............................................................................................................................ 761
Page 13
Table of Contentsxii Appendix A: Answers to the Test Your Knowledge Questions 763 Chapter 1 – Introducing Tools and Skills with .NET ................................................................ 763 Chapter 2 – Making the Most of the Tools in Your Code Editor ................................................. 765 Chapter 3 – Source Code Management Using Git .................................................................... 767 Chapter 4 – Debugging and Memory Troubleshooting ............................................................ 770 Chapter 5 – Logging, Tracing, and Metrics for Observability ................................................... 771 Chapter 6 – Documenting Code, APIs, and Services ................................................................ 773 Chapter 7 – Observing and Modifying Code Execution Dynamically ........................................ 774 Chapter 8 – Protecting Data Using Cryptography .................................................................... 776 Chapter 9 – Multitasking and Concurrency ............................................................................ 777 Chapter 10 – Dependency Injection, Containers, and Service Lifetime .................................... 778 Chapter 11 – Unit Testing and Mocking .................................................................................. 779 Chapter 12 – Integration and Security Testing ........................................................................ 781 Chapter 13 – Benchmarking Performance, Load, and Stress Testing ....................................... 782 Chapter 14 – Functional and End-to-End Testing of Websites and Services .............................. 784 Chapter 15 – Containerization Using Docker .......................................................................... 785 Chapter 16 – Cloud-Native Development Using Aspire ............................................................ 787 Chapter 17 – Design Patterns and Principles .......................................................................... 788 Chapter 18 – Software and Solution Architecture Foundations ................................................ 789 Chapter 19 – Your Career, Teamwork, and Interviews ............................................................. 791 Appendix B: Setting Up Your Development Environment 795 Installing Visual Studio, VS Code, or Rider ............................................................................. 795 Installing Docker and an SQL Server container image ............................................................ 803 Installing and setting up SQL Server locally ........................................................................... 817 Setting up Azure SQL Database ............................................................................................. 821 Rider tool window for working with SQL Server ..................................................................... 825 Appendix C: Looking For Help 827 Unlock Your Exclusive Benefits 847 Index 849
Page 14
Preface There are programming books that aim to be comprehensive references to individual subjects like security, dependency injection, unit testing, web testing, containerization, cloud deployment, design patterns, and soft skills including interview preparation. This book is different. It is a step-by-step guide to learning all those tools and skills for professional .NET developers. It is concise and aims to be a brisk, fun read that is packed with practical hands-on walkthroughs of each topic. The breadth of the overarching narrative comes at the cost of some depth, but you will find many signposts to explore further if you wish. In my experience, the hardest part of learning a new tool or skill is getting started. Once I have had the most important key concepts explained and been walked through some practical tasks, I then feel comfortable going deeper by exploring the official documentation on my own. You can feel confident experimenting on your own once you have seen how the basics work correctly. This book is best for those who already know the fundamentals of the C# language and .NET libraries, have built some apps and services with .NET on their own, and now want to learn skills that are more relevant for working with a team in a professional organization. I will cover the most important aspects of tools and skills for .NET professionals so that you can par- ticipate in conversations with colleagues about those tools and skills and get productive fast. Who this book is for This book is for .NET professionals seeking to enhance their expertise, as well as aspiring developers aiming to advance their careers in the field. This book caters to individuals eager to master essential .NET tools, refine their development practices, explore advanced techniques and cutting-edge tools, and prepare themselves for job opportunities and interviews in the competitive landscape of .NET development. What this book covers This preface briefly introduces each chapter. A longer description including why each topic is covered is in the first chapter.
Page 15
Prefacexiv Introduction Chapter 1, Introducing Tools and Skills for .NET, is about setting up your development environment. You can use Visual Studio, VS Code, Rider, or any other code editor. I also review in more detail what the rest of this book covers and why. You will create some class libraries for an entity model and database that we will use in projects in later chapters. The chapter ends by covering how to use this book with future versions of .NET, for example, .NET 11, expected to be released in November 2026, and .NET 12, expected to be released in November 2027. Tools Important tools for professional .NET developers include your code editor, Git, debuggers, and mem- ory analysis. Chapter 2, Making the Most of the Tools in Your Code Editor, is about the less commonly used tools built into Visual Studio, VS Code, and Rider. You will learn how to customize your editor and how to create code snippets and refactoring features. Chapter 3, Source Code Management Using Git, covers the most common tasks that you would perform with Git to manage your source code, especially when working in a team of .NET developers. Chapter 4, Debugging and Memory Troubleshooting, is about using the debugging tools in your code editor and about using tools in your code editor to track the usage of memory to improve your apps and services. Chapter 5, Logging, Tracing, and Metrics for Observability, is about how to instrument your code to enable observability during testing and production using telemetry. Skills Important skills for professional .NET developers include documentation, dynamic code, protecting data and code, implementing multitasking in your projects, and managing service dependencies. Chapter 6, Documenting Your Code, APIs, and Services, discusses how to best document your code to help other developers maintain it in future using comments, and how to document your services and APIs to enable other developers to call them as designed. Chapter 7, Observing and Modifying Code Execution Dynamically, introduces you to some common types that are included with .NET for performing code reflection and applying and reading attributes; work- ing with expression trees; and creating source generators. Chapter 8, Protecting Data and Apps Using Cryptography, is about protecting your data from being viewed by malicious users using encryption, and from being manipulated or corrupted using hashing and signing. You will also learn about authentication and authorization to protect applications from un- authorized users. Chapter 9, Multitasking and Concurrency, covers how to allow multiple actions to occur at the same time to improve performance, scalability, and user productivity for the applications that you build.
Page 16
Preface xv Chapter 10, Dependency Injection, Containers, and Service Lifetime, is about reducing tight coupling between components, which enables you to better manage changes and software complexity, and is especially important to performing practical testing that we cover in the next part of the book. Testing Important testing tools and skills for professional .NET developers include all types of testing, from unit testing to web user interface testing. Chapter 11, Unit Testing and Mocking, introduces testing practices that will improve your code quality. Unit testing is easy to get wrong and be useless, undermining the team’s trust. Get it right, and you will save time and money, and smooth the development process. Chapter 12, Integration and Security Testing, introduces two higher levels of testing, integration and security, that apply across all components of a solution. Chapter 13, Benchmarking Performance, Load, and Stress Testing, introduces how to properly use the BenchmarkDotNet library to monitor your code to measure performance and efficiency. Then you will see how to perform load and stress testing on your projects to predict required resources and estimate the costs of deployment in production. Chapter 14, Functional and End-to-End Testing of Websites and Services, introduces you to functional and end-to-end testing of service APIs and web user interfaces. Containerization Chapter 15, Containerization Using Docker, introduces you to the concept of containerization and spe- cifically using Docker to virtualize hosts for services in complex solution architectures. Chapter 16, Cloud-Native Development Using Aspire, introduces you to Aspire, an opinionated way to manage a simulated cloud-native development environment on your local computer. Design and Career Important design skills for professional .NET developers include common coding design patterns, algorithm implementations, and architectural patterns. Finally, you need to get the career you aspire to. To achieve this, you must impress with your job application documents and at an interview. Chapter 17, Design Patterns and Principles, introduces you to the SOLID design patterns as well as other common design patterns like Singleton and Factory used by .NET. Chapter 18, Software and Solution Architecture Foundations, covers software and solution architecture including Clean Architecture. Chapter 19, Your Career, Teamwork, and Interviews, covers working in a team as a career professional, applying for jobs, and passing interviews for .NET software engineer and related job positions. This chapter includes 60 commonly asked questions in interviews. The first three questions have suggested answers in the print book. The full set of 60 questions and suggested answers are available online from the following link: https://github.com/markjprice/tools-skills-net10/blob/main/docs/ interview-qa/readme.md.
Page 17
Prefacexvi Epilogue, describes your options for further study to master the tools and skills you need to become a well-rounded professional .NET developer. Appendix A, Answers to the Test Your Knowledge Questions, has the answers to the test questions at the end of each chapter. Appendix B, Setting Up Your Development Environment, has step-by-step instructions for setting up your development environment. This includes a code editor such as Visual Studio or VS Code, and a database named Northwind on a database server such as SQL Server in Docker, SQL Server locally, or Azure SQL Database in the cloud. Appendix C, Looking For Help, is all about how to find quality information about programming on the web. You will learn about Microsoft Learn documentation, including its new MCP server for integra- tion with AI systems, getting help while coding and using dotnet commands, getting help from fellow readers in the book’s Discord channel, searching the .NET source code for implementation details, and finally making the most of modern AI tools like GitHub Copilot. The Appendix chapters are available to download from a link in the README file in the GitHub repos- itory: https://github.com/markjprice/tools-skills-net10. You can also access a free PDF copy of the book (containing Appendix A, B, and C) through the following link: https://packtpub.com/unlock. Search for this book by name, ensure it’s the correct edition, and have your invoice ready. To get the most out of this book You can develop .NET projects using Visual Studio, VS Code, or a third-party tool like Rider. VS Code, Rider, and the command-line tools work on most operating systems, including Windows, macOS, and many varieties of Linux. Visual Studio is Windows-only because Visual Studio for Mac has been retired, does not officially support .NET 8 or later, and it reached its end of life in August 2024. Download the example code files You can download or clone solutions for the step-by-step guided tasks and exercises from the GitHub repository at the following link: https://github.com/markjprice/tools-skills-net10. If you don’t know how, then I provide instructions on how to do this in Chapter 1, Introducing Tools and Skills for .NET. We also have other code bundles from our rich catalog of books and videos available at https:// github.com/PacktPublishing. Check them out!
Page 18
Preface xvii Conventions used There are a number of text conventions used throughout this book. CodeInText: Indicates code words in text, database table names, folder names, filenames, file exten- sions, pathnames, dummy URLs, user input, and Twitter (X) handles. For example; “The Controllers, Models, and Views folders contain ASP.NET Core classes and the .cshtml files for execution on the server.” A block of code is set as follows: // Storing items at index positions. names[0] = "Kate"; names[1] = "Jack"; names[2] = "Rebecca"; names[3] = "Tom"; When we wish to draw your attention to a particular part of a code block, the relevant lines or items are highlighted: // Storing items at index positions. names[0] = "Kate"; names[1] = "Jack"; names[2] = "Rebecca"; names[3] = "Tom"; Any command-line input or output is written as follows: dotnet new console Bold: Indicates a new term, an important word, or words that you see on the screen, for example, in menus or dialog boxes. For example: “Clicking on the Next button moves you to the next screen.” Warnings or important notes appear like this. Tips and tricks appear like this.
Page 19
Prefacexviii Get in touch Feedback from our readers is always welcome. General feedback: If you have questions about any aspect of this book or have any general feedback, please email us at customercare@packt.com and mention the book’s title in the subject of your message. Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit http://www.packt.com/submit-errata, click Submit Errata, and fill in the form. Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material. If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http://authors.packt.com/. Share your thoughts Once you’ve read Tools and Skills for .NET 10, Second Edition, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback. Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Page 20
Free Benefits with Your Book This book comes with free benefits to support your learning. Activate them now for instant access (see the “How to Unlock” section for instructions). Here’s a quick overview of what you can instantly unlock with your purchase: Free PDF copy with appendices Next-Gen Web-Based Reader Access a DRM-free PDF copy of this book to read anywhere, on any device. Multi-device progress sync: Pick up where you left off, on any device. Unlock the book’s appendices included with the free PDF. Highlighting and notetaking: Capture ideas and turn reading into lasting knowledge. Bookmarking: Save and revisit key sections whenever you need them. Dark mode: Reduce eye strain by switching to dark or sepia themes.
The above is a preview of the first 20 pages. Register to read the complete e-book.

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List