Skip to main content

Posts

Showing posts from 2025

Detecting breaking changes in your OpenAPI metadata

For the last 2 days I have been struggling with a breaking change I had in my ASP.NET Core web api that caused the consuming application to fail. I had a header parameter that was optional but became required after changing the nullability of my project to enabled . Although I found the issue and was able to fix it quite fast, I was not happy with my current process and was wondering how I could prevent this from happening again. This brought me to a final solution where I introduced some extra tests that compared the OpenAPI metadata between different implementations. Let me show you how I did it… Generate OpenAPI documents at build time To compare 2 OpenAPI metadata documents we first need to get them. For the already released version of the API, I can download the document through the OpenAPI endpoint ( /openapi/v1.json by default). But what about the new version of the API that is still in development? I solve this by generating the OpenAPI document at build time. This m...

Making a header parameter required in ASP.NET Core

Yesterday I talked about a breaking change I had inside my ASP.NET Core web api that caused my application to fail. I had a header parameter that was optional but became required after changing the nullability of my project to enabled . My hope was that this would be visible in the OpenAPI metadata for my OpenAPI. Unfortunately, the generated metadata always looked like this: So both this code: and this code: return exactly the same metadata. The lack of a required property marks this header as optional, which doesn't reflect the actual behavior of the application after enabling nullability. I decided to investigate this a little further and found out that it is possible to emit the correct metadata by explicitly adding a [Required] attribute to the parameter: After adding this attribute the metadata was updated correctly. It’s unfortunate that ASP.NET Core doesn’t do this by default as it is aware of the possible nullability of the provided parameters.

API contracts and nullability in ASP.NET Core

Although it is not the first time that I stumble over the nullability feature and breaking changes, this one still caught me by surprise. Let me first explain the context; I have an application built in ASP.NET Core with the nullability feature still disabled. As I had to make some changes to the API, I though it was a good timing to enable the nullability feature to help me avoid nullreference exceptions. As always I started by updating the application to enable the nullability feature. Therefore set the nullable value to enabled inside the csproj file: After enabling the feature, our integration tests started to fail. Here is the specific error message that got returned: In our API we have the option to pass an optional(!) X-Environment header parameter. We use this attribute to avoid that the API is accidently called from our development or test environment. In our original API implementation this attribute is optional; in case the attribute is ommitted we don’t do the en...

Repeating a test multiple times in C#

In JUnit you have the @RepeatedTest annotation. This annotation allows you to run a single test method multiple times with different execution contexts. Unlike simply calling a method in a loop, each repetition is treated as a separate test execution with its own lifecycle. Although it can be useful to discover and investigate race conditions, I never had a good reason to start using this kind of functionality. But with the introduction of AI workloads inside my applications, times have changed. As AI output is less deterministic, it now starts to make sense to run the same test multiple times as the AI output could differ from test run to test run. Let me show you how to do this using NUnit and XUnit... NUnit: Built-in Repeat Attribute NUnit provides the most elegant solution with its built-in [Repeat] attribute: XUnit: Using Theory and Custom Attributes XUnit doesn't provide an out-of-the-box equivalent to the @RepeatedTest annotation but you can build your own ...

Improve your GitHub Copilot prompts with the Prompt Boost extension

If you are new to GitHub Copilot or other AI coding assistants, it can be a challenge to get good results as you are still learning on how to write good prompts. What if there was a way to automatically transform your basic prompts into comprehensive, context-rich instructions that consistently produce better results? Enter Prompt Boost , a VS Code extension that bridges the gap between what you quickly type and what AI models actually need to generate high-quality, relevant code. What is Prompt Boost? Prompt Boost is a VS Code extension created by Chris Dias that enhances your prompts by adding relevant technical context, best practices, and specific requirements. Instead of sending bare-bones requests to GitHub Copilot, it helps you create detailed instructions that lead to more accurate and useful responses. The extension transforms your basic prompts into comprehensive specifications. Here's a real example of the transformation: Before (Basic prompt): Create a new l...

Compiler error ASPIRE007 after upgrading Aspire

After upgrading the .NET Aspire NuGet packages to the latest version on one of my projects, I started to get the following compiler error: 'Project' requires a reference to "Aspire.AppHost.Sdk" with version "9.0.0" or greater to work correctly. Please add the following line after the Project declaration <Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" /> . The error message is self explanatory and clearly defines how we could fix this. Add the Sdk reference to your csproj file to get rid of this compiler error: The strange thing was that after applying the upgrade on one branch, I also started to get the same compiler error on other branches although the Aspire NuGet were not (yet) upgraded on these branches. Bizar! More information Compiler Error ASPIRE007 - .NET Aspire | Microsoft Learn

Property based testing - Updating FsCheck to version 3.x

f you have never heard about Property based testing, I would recommend to check my blog series about it first. But if you are too lazy to go through all these posts, here is a short definition: Property-based testing is a powerful testing methodology used in software development to verify that a system behaves correctly across a wide range of inputs. Instead of writing individual test cases with specific inputs and expected outputs, property-based testing defines properties —general rules that should always hold true for a given system. It serves as an alternative to example based testing where we focus on a set of example cases to validate the behavior of our code. There are a lot of libraries out there that help you write Property Based Tests. In .NET I mainly use FSCheck and CSCheck . As I’m doing more and more Python, I also start using Property Based Tests there through Hypothesis . In this post I’ll focus on FSCheck and how to update to the latest version as some breakin...

Speed up your Git experience by enabling the commit graph algorithm

While working in Visual Studio today I noticed a message appear at the top my idea. The message stated the following: Speed up your git experience in Visual Studio by enabling the git commit graph algorithm. No idea what that exactly means but that sounds promising… so let’s find out Why this commit graph algorithm? Git repositories can become sluggish as they grow in size and complexity. If you've ever waited impatiently for git log to load or noticed that branch operations take longer than they should, you're not alone. Recently, Git introduced a powerful feature that can dramatically improve performance: the commit graph algorithm. The commit graph is a data structure that Git uses to store precomputed information about your repository's commit history. Instead of traversing the entire commit tree every time you run commands like git log , git merge-base , or git show-branch , Git can use this precomputed graph to answer queries much faster. Think of it ...

LLM timeline

Not a long post today, just an interesting visualization I noticed; the LLM timeline . This timeline shows the fast evolution of large language models over time starting from the original "Attention Is All You Need" paper by Google researchers to today's cutting-edge models. Nice! A big thank you to Michael Gathara for creating and maintaining this visualization. More information Attention Is All You Need LLM Timeline

.NET 9–OpenAPI and Scalar–Passing an API key

Let's continue our joruney in discovering Scalar . Today I want to talk about how we can integrate security. Most API's that we build today are secured in a way. This could be as simple as an API key or as complex as using OAuth with PKCE. In this post we’ll look at how to pass an API key through the Scalar UI. Let’s dive in… I assume that you already have registered an authentication scheme for your API like this: Now we need to write an extra transformer to include the authentication information in our OpenAPI metadata. Don’t forget to register this transformer in our OpenAPI configuration: At the Scalar level we don’t have to change anything: But if we now browse to the Scalar UI, the authentication scheme is recognized and we get the option to pass an API key:   Nice! More information .NET 9–OpenAPI and Scalar–Introduction .NET 9–OpenAPI and Scalar–Adding custom headers

Get an overview of task duration of Windows Scheduled Tasks

A long time ago, we made the decision to implement some features using batch processes that were scheduled to run at night (most of them as scheduled tasks). Over time the list of batch processes has further grown, with 85 processes running almost every night today. A sad record... Our business has further evolved and were it originally made sense to schedule all this work outside the regular business hours, we now encounter the following issues: The list of remaining free time slots is getting smaller and smaller, making it almost impossible to schedule a new task without interfering with other tasks. As our datasets have grown over the years, these processes typically also take longer and longer to execute. Our customers are interacting with our services more and more outside the regular business hours. It is no longer acceptable for our business to have to wait for some data. Realtime info is key to take correct business decisions. Some of these batch processes ar...

Generate Terraform configuration files from your Azure resources

While everyone is focusing all the announcements at Build 2025, I'm still processing some of the older recently announced features. A feature that I am happy that is finally available in preview is the Terraform export functionality in the Azure Portal. A similar feature already exists for some time for ARM and Bicep but now we can finally export to Terraform configuration files as well. Let’s give it a try… A short walkthrough Go to the Azure portal and browse to a specific resource. From there go to the Automation section and click on Export template . Click on the Terraform tab. The first time I did this I got the error below:   The reason is that you first need to register the Microsoft.AzureTerraform resource provider at the subscription level. Go to your Subscription in Azure. There open the list of Resource Providers .   Search for Microsoft.AzureTerraform resource provider and click on Register .   It can take some ...

The (non) sense of organization charts

Today while explaining my son how our heating system works, it brought me back to my earlier post about organization charts. Same as in heating system where you have a heating loop and a control loop, 2 loops exist in every organization. The first is formal and visible—it's drawn out in neat boxes and lines as your organizational chart, showing who reports to whom and where decisions get made. The second is informal and largely invisible—it's the actual pathways through which information, ideas, and real work flow to get things done. The two flows of organizational systems When we apply systems thinking to organizations, we can identify two critical flows that determine how effectively an organization functions: Control flow represents the formal authority structure—who has decision-making power, who approves what, and how accountability flows up and down the hierarchy. This is what your org chart captures beautifully with its clean boxes and reporting lines. Informat...

.NET 9–OpenAPI and Scalar–Adding custom headers

In this post I continue my investigation of using Scalar as an alternative to Swashbuckle that I was using before to expose my OpenAPI metadata in a userfriendly way. If you have no idea what Scalar is, I would recommend to check out my introduction post first before you continue reading. Today I want to have a look at how we can transform the OpenAPI metadata. On this specific API, it is expected that one of a set of custom headers is passed when calling the API. To simplify the experience, I originally created  an IOperationFilter for Swashbuckle to show these extra headers: How to customize the OpenAPI metadata in .NET 9? The generated OpenAPI document can be customized using “transformers”, which can operate on the entire document, on operations, or on schemas. Transformers are classes that implement the IOpenApiDocumentTransformer , IOpenApiOperationTransformer , or IOpenApiSchemaTransformer interfaces. Each of these interfaces has a single async method that receives...

The servant leadership paradox - When org charts contradict culture

In boardrooms and mission statements across the globe, "servant leadership" has become the philosophy du jour. Leaders proudly proclaim their commitment to serving their teams, inverting the traditional power structure, and putting employees first. Yet something curious happens when you ask to see their organizational charts. There they are—the familiar pyramids with executives perched at the top, managers in the middle, and the frontline workers—those actually creating value—relegated to the bottom or, in many cases, not represented at all. This visual contradiction begs the question: Can an organization truly embody servant leadership when its very structure portrays the opposite relationship? The telling power of visuals I think that organizational charts are more than administrative tools—they're powerful symbols that communicate "how things really work around here." When leadership teams espouse servant leadership while maintaining traditional hiera...

.NET 9–OpenAPI and Scalar–Introduction

With the release of .NET 9 , Microsoft has removed Swashbuckle from the default Web API templates. If you have never heard about Swashbuckle before, it allowed you to generate OpenAPI metadata for your web api's. Although I had no complaints using the Swagger UI, I decided to use the opportunity to have a look at library, Scalar, to generate an UI based on the OpenAPI documentation. In this post, I’ll walk you through my transition from Swashbuckle to Scalar, highlighting the benefits, challenges, and key implementation steps. Why the change? Microsoft decided to drop Swashbuckle due to maintenance issues and a shift toward integrated OpenAPI support . While Swashbuckle provided automatic documentation , Swagger UI integration , and customizability , Scalar introduces a sleek UI , mobile-friendly interface , and enhanced search capabilities . Scalar not only provides great integration for .NET but also works on a lot of other platforms. Setting Up Scalar in .NET 9 To i...

Why you should clean up your test directories

Today I lost a lot of time investigating a stupid(aren’t they all?) issue with some failing tests on the build server. The strange thing was that when I ran the same tests locally, they always succeeded...what was going wrong? Just for completeness, here is the test task configuration I was using: Nothing special I would think. It was only when diving deeper into the build output that I discovered what was going wrong. Here is the output that explains the problem: 2025-05-20T13:19:22.3855459Z vstest.console.exe 2025-05-20T13:19:22.3855564Z "D:\b\3\_work\210\s\IAM.Core.Tests\bin\Release\ net6.0\IAM.Core.Tests.dll " 2025-05-20T13:19:22.3855657Z "D:\b\3\_work\210\s\IAM.Core.Tests\bin\Release\ net8.0\IAM.Core.Tests.dll " 2025-05-20T13:19:22.3855761Z "D:\b\3\_work\210\s\Mestbank.Core.Tests\bin\Release\net6.0\Mestbank.Core.Tests.dll" 2025-05-20T13:19:22.3855857Z "D:\b\3\_work\210\s\Mestbank.Core.Tests\bin\Release\net8.0\Mestbank.Core.Tests....

Static File handling in ASP.NET Core 9.0

I know, I know, .NET 10 is already in preview and I am still catching up on what was added to .NET 9.0. Today while upgrading an older application to .NET 9, I decided to have a look at the new static file handling introduced in .NET 9 through the MapStaticAssets feature. Static File middleware (before .NET 9) Before .NET 9, static files(Javascript, CSS, images, …) were handled through the UseStaticFiles middleware This middleware is still there as the new MapStaticAssets feature does not support all the features that the original middleware had. From the documentation : Serving files from disk or embedded resources, or other locations Serve files outside of web root Set HTTP response headers Directory browsing Serve default documents FileExtensionContentTypeProvider Serve files from multiple locations Serving files from disk or embedded resources, or other locations Serve files outside of web root Set HTTP response headers Direc...

WSFederation broken after upgrade to .NET 8

This week a colleague contacted me with an issue he encountered after upgrading to .NET 8.0. On the project involved we were using the WsFederation middleware to authenticate and interact with ADFS. However after upgrading to .NET 8 and the 8.x version of the Microsoft.AspNetCore.Authentication.WsFederation middleware the trouble began. Using this version resulted in a change in behavior as suddenly the middleware starts to expect a SAML 2.0 token instead of a SAML 1.1 token that is now issued by our ADFS server: XmlReadException: IDX30011: Unable to read XML. Expecting XmlReader to be at ns.element: 'urn:oasis:names:tc:SAML:2.0:assertion.Assertion', found: 'urn:oasis:names:tc:SAML:1.0:assertion.Assertion'. Although I found a post online that it would be technically possible to let ADFS return a SAML 2.0 token through WSTrust, this doesn’t fit in the passive federation scenario we had, so time to look at some alternative solutions. Attempt 1 – Reverting to an ...

Troubleshooting a SQL timeout issue

I got contacted by someone from my team that INSERTs were failing on one of our database instances. A look at Application Insights showed the following error message in the logs: System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. For an unknown reason, the transaction timeout before it could be committed resulting in a rollback operation and a failing INSERT.  Time to open SQL Server Management Studio and first take a look at the Resource Locking Statistics by Objects report: Indeed, multiple sessions share a lock on the same table. If you want, you can also check the User Statistics report to find out what these sessions are related to:   To fix the issue, I killed the sessions that were causing the lock: KILL 236 KILL 210 KILL 257 After doing that, I could confirm that the locking was gone by refreshing the report: More information Sql...

Managing technical debt like financial debt

Yesterday on my way home, I was listening to the SoftwareCaptains podcast episode with Mathias Verraes (sorry, the episode is in Dutch). One of the topics discussed was technical debt and the  question was raised why (most) organizations manage very carefully their financial debt, they don’t apply the same rigor for their technical debt. This triggered a train-of-thought that resulted in this post. Financial debt is meticulously tracked, reported, and managed. CFOs provide regular updates to boards about debt levels, leveraging ratios, and debt servicing costs. Detailed financial statements outline current liabilities, long-term obligations, and repayment schedules. Financial debt is visible, quantified, and actively managed. Yet technical debt—which can be just as crippling to an organization's future—often exists as an invisible, unquantified burden until it's too late. What if we managed technical debt with the same rigor as financial debt? The hidden cost of techni...

How to limit memory usage of applications in IIS

A while back I talked about a memory leak we had in one of our applications. As a consequence, it brought the full production environment to a halt impacting not only the causing application but all applications hosted on the same IIS instance. Although we found the root cause and fixed the problem, we did a post-mortem to discuss on how to avoid this in the future. In this post, I'll walk you through the practical strategies we implemented to limit and optimize memory usage for our applications running in Internet Information Services (IIS). n this guide, I'll walk you through practical strategies to limit and optimize memory usage for applications running in Internet Information Services (IIS). Understanding memory usage in IIS Before diving into solutions, it's important to understand how IIS manages memory. IIS runs web applications in application pools, which are processes (w3wp.exe) that host your web applications. Each application pool can consume memory ind...