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
Azure-Sync

Azure-Sync: Sync your Azure App Settings to local

Azure-Sync is a handy shell script tool designed to help .NET developers working with Azure App Services. Inspired by the functionality provided by the Azure Functions Core Tools (func cli), Azure-Sync allows you to retrieve all environment variables from a specified Azure App Service, including any Azure KeyVault secrets, and add them to your local .NET secrets. Check the source code on GitHub: mhdbouk/azure-sync How to use Azure-Sync Using azure-sync is straightforward. Here are the steps ...

May 25, 2024 · 2 min · Mohamad Dbouk
Secure On-Premise .NET Application with Azure Key Vault

Secure On-Premise .NET Application with Azure Key Vault

Suppose you have your Web App and Database server hosted locally on your On-Premises servers. You want to use Azure Key Vault with your .NET application to retrieve your app settings. This allows you to avoid storing them as plain text in the appsettings.json file. In this blog post, I will show you how to integrate Azure Key Vault with your .NET application by using the Service Principle client secret. This approach can be applied to any environment even the on-premise one. ...

February 9, 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
Bringing Blazor to Desktop and Mobile with MAUI

Bringing Blazor to Desktop and Mobile with MAUI

I wanted to host a Blazor WebAssembly application natively as a desktop application, and to achieve that, I planned to use a MAUI Blazor app. However, I wanted to avoid duplicating the Razor pages between both of my projects since I intended to continue using the web version as well. In this blog post, I will show you how to accomplish this. Consider using this approach to host your SaaS application in the cloud and simultaneously offer support for a native desktop app, much like Slack. ...

September 24, 2023 · 6 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
NuGet Unauthorized Access Issue

How to Resolve Unauthorized Access Issue with Private NuGet Repository

Have you ever encountered an issue while trying to restore packages from a private NuGet repository in JetBrains Rider using Azure DevOps? I recently faced a similar problem and struggled with the “401 Unauthorized” error. In this blog post, I will guide you through the steps I took to fix this issue. So, let’s dive in! Azure DevOps and Private NuGet Repositories Azure DevOps is a comprehensive platform that provides a range of tools for software development, including package management with NuGet. Private NuGet repositories in Azure DevOps allow you to host and manage your own packages. You may encounter authentication challenges when you try to restore packages from a private NuGet repository. ...

June 12, 2023 · 4 min · Mohamad Dbouk