Reproducible Builds and Snapshot Testing: Handling File Paths in .NET

 
 
  • Gérald Barré
Reproducible builds in .NET replace file paths with placeholder values to enable reproducible builds and prevent leaking local development paths in binary outputs. This is a common practice on CI/CD pipelines. However, libraries that rely on actual file paths to function, like snapshot testing frameworks, face a challenge: they need to know where to store and load snapshot files on disk. This post… [read more]

Snapshot testing in .NET with Meziantou.Framework.SnapshotTesting

 
 
  • Gérald Barré
Snapshot testing is a technique where the output of a function or component is serialized and saved to disk the first time the test runs. On every subsequent run, the library re-serializes the output and compares it against the saved file. If they differ, the test fails. Meziantou.Framework.SnapshotTesting is a .NET library that makes snapshot testing straightforward. It handles serialization, file… [read more]

Safely passing extra arguments in GitHub Actions workflows using PowerShell

 
 
  • Gérald Barré
When creating reusable GitHub Actions workflows or composite actions, you often need to allow callers to provide extra arguments to a command. For example, a workflow that builds a .NET project might accept additional arguments for dotnet build. Handling these arguments safely requires careful attention to prevent script injection and ensure proper argument splitting. The problem with direct interpolation… [read more]

Enable SHA Pinning for GitHub Actions Across Personal Repositories

 
 
  • Gérald Barré
Pinning GitHub Actions to a full-length commit SHA is one of the simplest ways to reduce supply chain risk in your workflows. It ensures that a workflow keeps using the exact code you reviewed, instead of silently following a moving tag or branch. Tags are convenient, but they are mutable. A workflow that uses actions/checkout@v4 or a third-party action pinned to a tag can start running different code… [read more]

Number comparison in .NET: ==, Equals, and IEEE 754 edge cases

 
 
  • Gérald Barré
When people compare numbers, they usually expect a simple rule: same value means equal. For floating-point numbers (Half, float, and double), there are actually two useful notions of equality in .NET: IEEE comparison semantics, used by == equivalence semantics for .NET objects, used by Equals At first sight this looks inconsistent. In practice, each one solves a different problem. Quick behavior matrix… [read more]

Generate a Kiota client at build time from an ASP.NET Core OpenAPI file

 
 
  • Gérald Barré
In a previous post, I explained how to generate the OpenAPI document during the ASP.NET Core build and commit it to the repository. That gives you a versioned API contract that is easy to review in pull requests. In this post, let's go one step further: use that generated OpenAPI file as the input for Kiota, so your typed .NET client is also generated during build. The goal is simple: The server produces… [read more]