How C# Records will change my life
Introduction Whenever I code I prefer to have immutable domain models. Example: public class Game { public Game(Team homeTeam, Team awayTeam, GameResult result) { HomeTeam = homeTeam ?? throw new...
View ArticleHeartbeat logger in Dotnet Core
Photo by Jair Lázaro / Unsplash Introduction It's important to monitor your applications so that you can act fast when problems occurs. When it comes to web applications it's common to have a /health...
View ArticleDotnet pack - include referenced projects
Photo taken by Vance Osterhout Scenario You provide a nuget package to x amount of different customers. You want to share common code between the different nuget packages. You don't want your shared...
View ArticleCustom Dictionary JsonConverter for System.Text.Json
Image taken by Romain Vignes Introduction A couple of months ago we (more or less unknowingly) started to use System.Text.Json instead of Newtonsoft in one of our ASP.NET Core applications. The...
View ArticleCSVHelper - Read column value into a List property
Photo by Mika Baumeister When working with C# and CSV files, I always use CSVHelper. It's a small library for reading and writing CSV files. Extremely fast, flexible, and easy to use. I couldn't agree...
View ArticleC# - Throttle outgoing http requests - Concurrent
Photo by Denys Nevozhai Introduction This is the first part in a series I'm planning to write about how to consume http apis with rate limiting in mind. This post will focus on how to handle rate...
View ArticleTidy up your HttpClient usage
Photo by CDC Introduction This is just a quick tip for anyone using HttpClient and wants to avoid some of the boilerplate (error handling, logging etc). Usually my implementations looks something like...
View ArticleMongoDB - Missing discriminator array when doing upserts with UpdateOneModel
The problem Given the following two classes: [BsonDiscriminator(RootClass = true)] [BsonKnownTypes(typeof(MongoDbSomeModel))] [BsonIgnoreExtraElements] public class MongoDbBaseModel { [BsonId] public...
View ArticleEfficient file uploads with dotnet
Introduction Recently I needed to solve the following problem at work We need to upload a lot of large files to a third party storage provider, it needs to be as efficient as possible. This problem is...
View ArticlePolymorphic deserialization with System.Text.Json
Photo by Florian Krumm The problem We need to deserialize the following JSON: [ { "type": "car", "name": "Josefs Car", "wheels": 4, "model": { "brand": "Ferrri", "name": "458 Spider", "color": "red",...
View ArticleAzure Storage - Zip multiple files using Azure Functions
Photo by Tomas Sobek Introduction Recently I was assigned the following task: Our customers need to be able to create a zip file containing multiple files from Azure Storage and then download it. It...
View ArticleMy take on the "Result class"
Photo by Agence Olloweb Introduction Don't use exceptions for flow control! This is a quote I stumbled on quite a bit during my first years as a programmer. Let's imagine the following scenario: We...
View ArticleSelect action method based on header value - ASP.NET Core
Photo by Constantin Shimonenko Scenario We are using a third party system for managing our users. Whenever something happens with a user (added/updated/removed...), the system will notify us by using a...
View ArticleWOPI Integration with ASP.NET Core - lessons learned
Photo by Nikhita S Introduction Recently I've been working on adding "Office for the Web" support to our system. This will enable us to edit office documents uploaded to our system directly in the...
View ArticleTransform C# objects to a flat string dictionary
Photo by Kenan Reed The problem Because of (third party) reasons I needed to transform some objects to a flat Dictionary<string, string>. Example Given the following class... public class MyClass...
View ArticleNew major version of JOS.ContentSerializer - Version 5.0
I finally had some time to fix a long standing bug in JOS.ContentSerializer. The bug If you passed in a custom IContentSerializerSettings to the Serialize or GetStructuredData method on...
View ArticleHow C# Records will change my life
Photo by Eric Krull Introduction Whenever I code I prefer to have immutable domain models. Example: public class Game { public Game(Team homeTeam, Team awayTeam, GameResult result) { HomeTeam =...
View ArticleNew major version of JOS.ContentSerializer - Version 5.0
I finally had some time to fix a long standing bug in JOS.ContentSerializer. The bug If you passed in a custom IContentSerializerSettings to the Serialize or GetStructuredData method on...
View ArticleHow C# Records will change my life
Photo by Eric Krull Introduction Whenever I code I prefer to have immutable domain models. Example: public class Game { public Game(Team homeTeam, Team awayTeam, GameResult result) { HomeTeam =...
View ArticleNew major version of JOS.ContentSerializer - Version 5.0
I finally had some time to fix a long standing bug in JOS.ContentSerializer. The bug If you passed in a custom IContentSerializerSettings to the Serialize or GetStructuredData method on...
View Article