Local AI Models in .NET

Run Local AI Models in .NET Like a Boss

You know that you don’t need to pay for AI services to get the job done, right? If you’re looking to run local AI models in your .NET applications, I’ve got just the thing for you. In this post, I walk you through how to set up and run local AI models using .NET, Docker, and Ollama. We’ll cover everything from installing the necessary tools to running your first model, and to building a simple application that uses these models. ...

August 6, 2025 · 5 min · Mohamad Dbouk
MediatR Alternative

I Built My Own MediatR! Here How You Can Too

So, MediatR’s changing things up, right? If you’re looking for a free way to handle messaging in your .NET apps, I’ve got something cool for you. In my latest video, I walk you through building your own alternative to MediatR. We’ll dive into the Mediator pattern, CQRS (Command Query Responsibility Segregation) and how to implement CQRS using the Mediator pattern. You’ll see how to set up the basics for sending commands and queries, and how to get the right code to handle them. ...

June 2, 2025 · 1 min · Mohamad Dbouk
HybridCache in .NET 9

HybridCache in .NET 9 is Awesome!

.NET 9 is now live, and it comes with a new set of features. Some are great, and some are just icing on the cake. But what really stands out is the new HybridCache! HybridCache is not just another caching API in .NET; it’s designed to solve problems we didn’t even know we had. It combines the best of two worlds by bridging the gap between IMemoryCache and IDistributedCache. It also introduces advanced features like cache stampede protection and efficient serialization. ...

November 23, 2024 · 3 min · Mohamad Dbouk
IFormattable

Adding Custom Formatting to Your Classes with IFormattable

DateTime has a great feature that I often replicate in my classes: the ability for users to format the ToString output however they want. Using it is cool, but building it yourself? Even better. In this post, I’ll walk you through implementing custom formatting for any class using the IFormattable interface, covering multiple approaches. You can also check out my YouTube video on the same topic here: https://youtu.be/hocPk1eBUuE What we’re aiming to achieve is similar to the ToString method with format options found in the DateTime class. ...

November 18, 2024 · 6 min · Mohamad Dbouk
Source Generator in .NET

Implement Builders easily with Source Generator in .NET

I created a YouTube video on Source Generator in which I showcased one possible implementation. However, I feel that I didn’t fully highlight its capabilities. In this blog post, I aim to demonstrate how to use the Source Generator to automatically create builders for a given class. Check the YouTube video and the source code here For our Builder Generator implementation, let’s start from scratch. Create a new class library project, name it SourceGenerator, add the necessary NuGet package references, and add a new class called AutoBuilderGenerator as shown in the code snippet below ...

February 28, 2024 · 4 min · Mohamad Dbouk
Integration Testing with Docker

Running Integration Tests with Docker in .NET using TestContainers

Hello everyone, in today’s post I will show you the easiest and cleanest way to perform integration testing of your code with database dependencies with the help of docker and TestContainers. Unlike unit tests where you can use In-Memory or Mock the database calls, integration tests need to test the actual calls to the database, and using an empty, In-Memory, database will not represent the reality of what the system is doing, or perhaps your code is tightly coupled with specific database behaviors or relies on certain configurations that an In-Memory setup won’t capture accurately. For that, we will use docker to run a dockerized database image and perform our tests against it. And for that, we will use TestContainers. ...

November 30, 2023 · 2 min · Mohamad Dbouk
CSharpRepl Logo

CSharpRepl – Your Ultimate C# Playground in the Terminal

So, listen up! CSharpRepl is this awesome command-line tool that allows you to get hands-on with C# programming without any hassle. With this tool, you can write, execute, and experiment with your code, all within your terminal. This means that you no longer have to create a new console app each time you want to test something in C#. It’s a great way to get hands-on with C# programming without any hassle. ...

October 7, 2023 · 1 min · Mohamad Dbouk
Tic Tac Toe Game with Blazor WebAssembly

Let's Build a Tic Tac Toe Game with Blazor WebAssembly!

Hey there, fellow developer! In this tutorial, I’ll walk you through building an awesome Tic Tac Toe game using Blazor WebAssembly. So grab your coding gear, and let’s get started! To check the full source code, you can visit github/mhdbouk/tictactoe-blazor. Step 1: Set Up the Blazor WebAssembly Project First things first, we need to set up a new Blazor WebAssembly project. Do your thing with the command line or your favorite IDE like Visual Studio or Visual Studio Code. Get that project ready for some Tic Tac Toe action! ...

August 29, 2023 · 9 min · Mohamad Dbouk
Mapperly Logo

Mapperly: The Coolest Object Mapping Tool in Town

Hey there, developers! Today I want to talk about an astonishing .NET library called Mapperly, which has been gaining much attention in the developer community. Mapperly is a powerful source generator that simplifies the implementation of object-to-object mappings in .NET applications. Mapperly takes mapping to a whole new level by generating mapping code for you based on the mapping method signatures you define. If you’re tired of writing repetitive mapping code and seeking a seamless solution to simplify object mappings in your .NET projects, Mapperly is the answer you’ve been waiting for. Join me in this blog post to learn more! ...

July 13, 2023 · 5 min · Mohamad Dbouk
Spectre.Console Logo

How to create beautiful console applications with Spectre.Console

Hey there friends! If you are a .NET developer who loves to create console applications, you might have wondered how to make them more appealing and user-friendly. Sure, you can use Console.WriteLine and Console.ReadLine to output some text and get some input, but that’s pretty boring and limited. What if you want to display some colors, styles, tables, trees, progress bars, or even ASCII images? What if you want to parse command-line arguments and create complex commands like git, npm, or dotnet? ...

March 19, 2023 · 6 min · Mohamad Dbouk