Using glob patterns in *.csproj files

Here's a cool article on simplifying your csproj files by using glob pattern for paths and file extensions https://mykeels.medium.com/using-glob-patterns-in-csproj-files-95122c7f0870 Glob patterns are like wildcard-based rules that match file paths. They let you specify file patterns using wildcards like * and ** to match multiple files with similar characteristics. In this case, we want to target all C# files (*.cs) … Continue reading Using glob patterns in *.csproj files

Creating Interactive Console Applications in C#

Console applications (or command line interfaces - CLI) have long been a staple for developers due to their simplicity and ease of use. However, with the right tools and techniques, you can build sophisticated console applications that are both interactive and user-friendly. Let's explore how to create advanced console applications in C# using Spectre.Console.Cli for … Continue reading Creating Interactive Console Applications in C#

Using GenericHost in a C# Console Application

Introduction Building useful console applications often requires structured logging, configuration management, and dependency injection. The .NET Generic Host framework provides a powerful foundation to enable these features. Let's explore how to use GenericHost in a C# console application, with a specific focus on creating a simple command-line parser. This parser will interpret and reprint command … Continue reading Using GenericHost in a C# Console Application

Creating a Fluent API in C#

Introduction Fluent API is a design pattern that provides more readable and intuitive code by chaining method calls together. This type of API is commonly used in implementing the Builder design pattern. This style enhances code readability, reduces boilerplate, and makes APIs easier to use. Fluent APIs are commonly seen in libraries like LINQ and … Continue reading Creating a Fluent API in C#

Parameter Validation Using ArgumentExceptions

In the latest .NET versions, argument validation has been streamlined with new helper extension methods that make it even easier and more expressive to throw argument exceptions. Some of these methods were first introduced in .NET 6 but have been enhanced with subsequent releases. Here are some of the latest ways to handle argument validation … Continue reading Parameter Validation Using ArgumentExceptions

Configure Visual Studio to Use File-Scoped Namespaces on New Classes

Filed-scoped namespaces were a new feature added to C# 10. File-scoped namespaces simplify the organization of code by allowing you to declare the namespace at the file level rather than wrapping each type in its own namespace block. This can lead to more readable and concise code with one less layer of curly braces in … Continue reading Configure Visual Studio to Use File-Scoped Namespaces on New Classes