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]

Understanding When Type.FullName Returns Null in .NET

 
 
  • Gérald Barré
A colleague recently asked me an interesting question: "Why does Type.FullName return null in certain situations?" Indeed, the method signature is public abstract string? FullName { get; } This behavior might seem unexpected, but there are specific scenarios where the .NET runtime cannot generate a valid full name for a type. Here are the two main cases where Type.FullName returns null: Generic Types with… [read more]

How to Find an Available Network Port for a server in .NET

 
 
  • Gérald Barré
When working with network programming in .NET, you might need to find an available port on your system. This is particularly useful when creating server applications, running tests, or developing tools that need to bind to a network port without conflicts. Here's a simple way to get an available port using the Socket class: Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,… [read more]

Using Git insteadOf to Automatically Replace HTTPS URLs with SSH

 
 
  • Gérald Barré
When working with Git repositories, you often encounter URLs in HTTPS format, especially when cloning from GitHub, GitLab, or other hosting services. However, if you prefer using SSH for authentication (which is often more convenient with key-based auth), manually changing URLs can be tedious. Also, it can be even harder when dealing with submodules. Git's insteadOf configuration option provides an… [read more]

Batch migrate .sln files to .slnx format across repositories

 
 
  • Gérald Barré
.NET has introduced a new solution file format called .slnx that offers significant improvements over the traditional .sln format: Better readability: XML-based structure that's human-readable Simplified merging: Reduces merge conflicts compared to the legacy format Easier parsing: Can be manipulated programmatically outside IDEs (for .NET devs, you can use microsoft/vs-solutionpersistence) To start using… [read more]

Open Windows Explorer to a Specific Path in C#

 
 
  • Gérald Barré
Sometimes, you need to open Windows Explorer to a specific folder from your C# application. This can be useful for improving user experience, providing quick access to files, or integrating with other tools. In this post, I'll show you how to achieve this using the Windows Shell API via the Microsoft.Windows.CsWin32 package, and discuss an alternative using Meziantou.Framework.FullPath. To use Windows… [read more]

Using Multiple Loopback Addresses for Socket Binding

 
 
  • Gérald Barré
127.0.0.1 is a reserved IP address that refers to the local machine. It is commonly used for testing and development purposes, allowing applications to communicate with themselves without needing an external network connection. But, the full range of loopback addresses is from 127.0.0.0 to 127.255.255.255 (127.0.0.0/8), which means you can use other addresses in this range for similar purposes. The… [read more]