Vaughan

C# 9.0: Readability improvements

.NET 5.0, C# 9.0

With the recent announcement of .NET 5.0 I’d like to spend some time going over some of the nice features you will get out the box if you upgrade. With .NET 5.0, you can start using C# 9.0 features and it has some nifty syntax changes that I think can make your code a little […]

Read more
Vaughan

Using Refit in ASP.NET Core to remove boilerplate code when consuming REST endpoints

.NET Core, Refit

I recently started using Refit in a project and its a really nice way to consume rest endpoints. Once you set it up, all you have to worry about is making a call against a interface and Refit will do all the work for you. As an example, imagine that I have a person REST […]

Read more
Vaughan

Code challenges: Finding number of sub arrays with a sum of zero

Algorithms, Performance

It can be fun to challenge yourself with algorithm type problems and to try find an optimal solution. Unfortunately the only way to get better at them is to practice. After enough practice you might start to spot common patterns to solve a new problem just based off experience. I challenged myself to solve the […]

Read more
Vaughan

Using MediatR in ASP.NET Core

.NET Core, MediatR

We recently started using MediatR in a project and its a great way to make your services simpler as requirements grow. I want to show a simple example to give an idea on why you would use it. I’ve created a person controller that has a search endpoint that in theory will get a Person […]

Read more
Vaughan

What is AyncLocal in C#?

.NET Core

An interesting class that is useful to know about but you most probably won’t directly use is AsyncLocal. It stores data local to the async flow. This means that if a method further down the chain changes the underlying value, the change will only apply to that and its children. A potential use case might […]

Read more
Vaughan

Why you should start using property based testing

.NET Core, Testing

I want to convince you to try Property-based testing in your projects. Its a really powerful approach when combined with classic unit testing. When we write a unit test we generally use what they call example based testing. What this means is that we create an expected response and run our test to confirm that […]

Read more
Vaughan

Classifying tweet sentiment with ML.NET

.NET Core, MachineLearning, ML.NET

Following from my previous post on getting paged data from twitter, I thought it would be interesting to use ML.NET to do a little analysis. A common problem solved with machine learning is doing sentiment analysis on text to evaluate how positive or negative something is. To solve this problem with ML.NET really isn’t that […]

Read more
Vaughan

Consuming paged Twitter data with async enumerable

.NET Core

A really nice feature in C# 8 is async enumerables. A popular use case is if you want to consume paged data and potentially aggregate each page of data without having to get everything first. Previously the consuming code would have to handle the paging but now your method can just enumerate over the IAsyncEnumerable […]

Read more
Vaughan

Creating an AWS Lambda function written in C# .NET Core

.NET Core, AWS

With more and more companies moving to the cloud, the idea of serverless execution of your code has more and more appeal. AWS has Lambda and Azure has Functions. The idea is the same: You give them a method that you want to execute and the provider works out the scaling. As you get more […]

Read more
Vaughan

ASP.NET Core integration tests with WebApplicationFactory

.NET Core, Testing

We all agree that we want to have tests that cover as much of our application as possible. Right? The general approach with ASP.NET applications has been to extract meaningful business logic out of your controllers. Pretty much everything that needs to be tested would be injected with an interface so that its easy to […]

Read more

BMC logoBuy me a coffee