Skip to main content

Posts

Showing posts from September, 2026

TDD in C# with xUnit and Moq: Complete Tutorial

Learn test-driven development in C# with xUnit and Moq. Step-by-step TDD tutorial with runnable code, mocking, best practices. Start writing tests first! What Is Test-Driven Development in C#? Test-driven development (TDD) in C# flips the traditional workflow on its head: you write a failing unit test first , then write just enough production code to make it pass, and finally refactor with confidence. Combined with xUnit (the most popular .NET testing framework) and Moq (the go-to mocking library), test-driven development in C# gives you a fast feedback loop, a living specification of your code's behavior, and a safety net that makes refactoring painless instead of terrifying. In this tutorial you'll build a small but realistic feature — an order service with a payment gateway dependency — entirely test-first. Along the way we'll cover the red-green-refactor cycle, mocking with Moq, best practices, and the pitfalls that trip up most teams when they adopt TDD. Why ...

C# Async/Await Complete Guide 2026: Examples & Mistakes

Master C# async await with this complete 2026 guide. Real-world examples, best practices, and common mistakes to avoid. Start writing faster async code today. If you've ever wondered how C# async await really works — or why your "asynchronous" code still freezes the UI or deadlocks in production — this complete guide is for you. Asynchronous programming is one of the most searched C# topics on Google, and for good reason: nearly every modern .NET application, from ASP.NET Core APIs to desktop apps, depends on async and await to stay responsive and scalable. In this 2026 guide, we'll cover how async/await works under the hood, real-world examples you can run today, best practices, and the common mistakes that trip up even senior developers. What Is Async/Await in C#? The async and await keywords, introduced in C# 5, let you write asynchronous code that reads like synchronous code. Instead of blocking a thread while waiting for a slow operation — a database ...

.NET Performance Profiling: dotTrace & PerfView Guide

Learn .NET performance profiling with dotTrace and PerfView. Find CPU, memory, and async bottlenecks in C# apps — step-by-step tutorial with code. Why .NET Performance Profiling Beats Guessing Every Time Every developer has been there: the app is slow, someone on the team says "it's probably the database," someone else blames the ORM, and an afternoon disappears into changing code that was never the problem. .NET performance profiling replaces that guesswork with measurement. Instead of asking "what do we think is slow?", a profiler answers "here is exactly where your CPU time, memory allocations, and wall-clock time went." In this guide, you'll learn how to find and fix real bottlenecks in C# applications using two of the best tools in the ecosystem: JetBrains dotTrace and Microsoft's free PerfView. The reason profiling matters so much is a hard statistical truth: performance problems are almost never evenly distributed. In most applica...

AWS vs Azure vs GCP for .NET Developers in 2026

AWS vs Azure vs GCP compared for .NET developers in 2026. Pricing, C# support, deployment & real code examples. Find the best cloud for your .NET apps. If you're a .NET developer in 2026, the AWS vs Azure vs GCP debate is no longer academic — it directly affects your deployment speed, your monthly bill, and even your job prospects. All three clouds now offer first-class .NET support, but they are far from interchangeable. In this guide, we'll compare the big three from a purely C#/.NET perspective: SDK quality, serverless support, container hosting, pricing, and developer experience — with runnable code for each platform, so you can decide which cloud is best for your next .NET project. TL;DR: Which Cloud Is Best for .NET Developers in 2026? Azure — the default choice for most .NET teams. Deepest integration with Visual Studio, .NET Aspire, Entra ID, and enterprise Microsoft stacks. AWS — the biggest job market and the most mature serverless platform. .NET o...

Fine-Tune AI Models & Call Them From C# (2026 Guide)

Learn how to fine-tune AI models and call them from C# with OpenAI and Azure OpenAI. Step-by-step code examples inside — start building today. Why Fine-Tuning AI Models Matters for C# Developers Fine-tuning AI models is one of the most searched-for skills in modern software development — and for good reason. While base models like GPT-4o and Claude are impressively general, they don't know your company's tone of voice, your domain-specific terminology, or your internal classification rules. Fine-tuning solves this: you take a pre-trained model and continue training it on your own examples, producing a custom model that responds exactly the way your business needs. In this guide, you'll learn how fine-tuning works, when to use it (and when not to), how to prepare training data, how to run a fine-tuning job, and — most importantly for us — how to call your fine-tuned model from a C# application using .NET 8/9. Here's the WHY before the HOW: a fine-tuned smaller mode...

Vertical Slice Architecture in .NET: A Complete Guide

Learn vertical slice architecture in .NET with C# examples. Organize code by feature, not layer — with MediatR, minimal APIs, and best practices. Start now! What Is Vertical Slice Architecture in .NET? Vertical slice architecture is a way of organizing your .NET codebase by feature instead of by technical layer . Rather than spreading a single feature across a Controllers folder, a Services folder, a Repositories folder, and a DTOs folder, you put everything that feature needs — the endpoint, the request, the handler, the validation, and the data access — into one folder, one "slice." When you need to change how "Create Order" works, you open one folder, not five projects. The term was popularized by Jimmy Bogard (creator of MediatR and AutoMapper), and it has become one of the most talked-about approaches to ASP.NET Core project structure. In this guide, you'll learn why vertical slice architecture is winning over teams that used to swear by n-tier and ...

What Is Zero Trust Security? Architecture Guide 2026

Learn what zero trust security is, its core principles, architecture, and how to implement it in C# and .NET. Complete 2026 guide with code examples. Zero trust security is a cybersecurity model built on one simple rule: never trust, always verify . Unlike traditional perimeter-based security — where anyone inside the corporate network is trusted by default — zero trust assumes that every request, whether it comes from inside or outside the network, could be hostile. Every user, device, and service must prove who they are and what they're allowed to do, every single time. In 2026, with hybrid work, cloud-native applications, and AI-driven attacks being the norm, zero trust security has moved from a buzzword to a baseline requirement for enterprises in the USA, UK, Canada, Australia, and India. In this guide, you'll learn what zero trust security is, the core principles behind the zero trust architecture, and — because this is csharp-coder.com — how to actually implement ...