Understanding and Managing Mark of the Web in .NET

 
 
  • Gérald Barré
What is Mark of the Web? Mark of the Web (MOTW) is a Windows security feature that protects users from potentially unsafe files downloaded from the internet. When you download a file, Windows automatically adds a special metadata tag indicating the file originated from an untrusted source and may contain harmful content. Windows components such as Microsoft Edge and Windows Explorer use MOTW to determine… [read more]

Resolving Overload Ambiguity with Collection Expressions

 
 
  • Gérald Barré
OverloadResolutionPriority allows you to specify which method overload should be preferred by the compiler when multiple overloads are applicable. This can be useful in scenarios where you have multiple methods with types that can be implicitly converted to each other, and you want to control which overload is chosen. I've found this feature particularly useful when having existing overloads that take… [read more]

Creating a custom MSBuild SDK to reduce boilerplate in .NET projects

 
 
  • Gérald Barré
This blog post is part of The C# Advent Calendar 2025, a series of 50 posts about C#. Be sure to check out the rest of the blog posts in the calendar! Over the years, I've relied on Meziantou.DotNet.CodingStandard, a NuGet package, to establish a consistent baseline across all my .NET projects. This approach includes style enforcement, essential analyzers, sensible build defaults, and additional tooling.… [read more]

Update Local Git Branches Without Switching

 
 
  • Gérald Barré
If you frequently need to work on multiple branches simultaneously, consider using Git Worktree to maintain separate working directories for each branch, eliminating IDE reloads entirely. When you need to switch to a branch that is not up to date with the remote branch, the typical workflow involves switching to that branch and pulling the latest changes. This process can be time-consuming and disruptive… [read more]

Optimize GUID creation performance in .NET applications

 
 
  • Gérald Barré
Many .NET projects use well-known GUIDs as identifiers for activities, interop scenarios, database keys, and other purposes. It's common to see code like new Guid("01234567-8901-2345-6789-012345678901") throughout applications. While this approach is readable and straightforward, it comes with a hidden performance cost that can impact application startup time. This is a micro-optimization that primarily… [read more]

C# 14 Extension Members: Enhancing Polyfill Libraries

 
 
  • Gérald Barré
C# has long supported extension methods, allowing developers to add new methods to existing types without modifying the original type. However, this capability was limited to instance methods. With C# 14, the language introduces extension members, significantly expanding what you can extend. You can now add extension properties and extension static methods to existing types. This enhancement is… [read more]

Using Git Conditional Includes for Multiple Configurations

 
 
  • Gérald Barré
When working across multiple Git repositories, you often need different configurations for each context. For example, you might use your personal email for open-source contributions and your work email for company projects. While you can configure Git globally or per repository, managing these settings manually becomes tedious and error-prone. Git's conditional includes feature solves this problem by… [read more]

Flushing Disk Caches on Windows: A Comprehensive Guide

 
 
  • Gérald Barré
When working with file systems on Windows, understanding and controlling disk caching is crucial for ensuring data integrity and optimizing performance. Disk caching improves system performance by temporarily storing write operations in memory before committing them to disk. However, this also means that in case of power failure or system crash, data might be lost if it hasn't been flushed from cache to… [read more]