The C# 9 init-only setters

In a previous post in which we discussed about the Null Object Pattern, we discussed of a hackish approach to make sure that the default properties cannot be changed. Please note that the code snippets from this post have been run in LinqPad so they can be used as is, to run them in Visual … Continue reading The C# 9 init-only setters

Creating zips server side per request

Hello and welcome 😀, Today's post will focus on a situation I encountered recently, and that is How to create a zip archive on demand to be served via an API endpoint. In a following post, we will see how to receive a file from an AJAX call since there's some trickery involved there as … Continue reading Creating zips server side per request

Mocking LINQ Expressions

Hello and welcome In today's post, we will discuss mocking/stubbing lambda expressions so that we can have a bit more control over our unit tests. Keep in mind that I'm by no means versed in expression trees so I will try my best to explain. What is an Expression and how to use it Going … Continue reading Mocking LINQ Expressions

The rise of the Null-Object pattern in C# 8

Hello and welcome, As I probably mentioned in some of my older posts, I'm a big fan of code restrictions that can be imposed by the IDE. I think this is a reason why stylecop was/is so popular (I don't know since I mostly use Rider nowadays and Resharper for Visual Studio). Because of this, … Continue reading The rise of the Null-Object pattern in C# 8

Typed claims in ASP.Net Core 2.1

Hello and Welcome 🙂 Today I want to discuss about how we can use claims following a typed approach, this topic came about from a bug that was encountered during a code review for an application. As such I wanted to find a way of mitigating such issues in the future by using concrete classes … Continue reading Typed claims in ASP.Net Core 2.1

Application triggers for Asp.Net Core 2.1 entity framework core

Hello and welcome 🙂 Today I wanted to talk about extending your application and your DbContext to run arbitrary code when a save occurs. The backstory While working with quite a few applications that work with databases especially using entity framework, I noticed the pattern of saving changes to the database and then do something … Continue reading Application triggers for Asp.Net Core 2.1 entity framework core

Compression and decompression snippets

Hello and Welcome 🙂 Today I want to look at a few extension methods to help with compressing either string or just byte arrays (which could be files, images, objects, basically, everything can be represented as a byte array). The backstory The need for this came when I was participating in a hackathon (in which … Continue reading Compression and decompression snippets

Branching authentication in Asp.Net Core 2.1

Hello and welcome 🙂 In the last post I hinted at using SignalR and query strings to branch how a user is authenticated. Backstory I ended up in this scenario when one of the requirements for the system was that it needs to be embedded into the client's system, that means that we would have … Continue reading Branching authentication in Asp.Net Core 2.1

SignalR metadata for Asp.Net Core 2.1

Hello and welcome 🙂 This will be a short post which will tie in with the next post about branching authentication in asp.net core using middleware. The problem Recently I encountered a situation in which I needed to pass to a SignalR hub additional data with every request, kinda like environment metadata from external systems. … Continue reading SignalR metadata for Asp.Net Core 2.1