Close

.Net

RedStar.Amounts to Avoid Primitive Obsession

I’ve been programming for more than 10 years now, and only recently heard about Primitive Obsession. I’ve been guilty of this now and then. But I’ve also written/extended a library that tackles exactly that. Primitive Obsession is the use of primitive data types (i.e. strings, integers, doubles, etc.) for simple tasks, instead of using small […]

Read More

RedStar.Amounts ported to .NET Standard 2.0

Almost a year ago now, I introduced RedStar.Amounts, a .NET library to handle units and amounts in an easy way. The code It allows you to explicitly state what unit a certain amount is measured in. So instead of doing this:

You can do this:

What’s more, you can perform calculations without having […]

Read More

Introducing RedStar.Amounts

How many times have you had to ask a colleague what unit that external application is using? Or worse, had bugs because you forgot to divide by 100? In many applications, it is common to change values when they are received by dividing or multiplying them. This is done because the other application uses centimeters, […]

Read More

C# string magic

In C#, you need strings often. Less often, you need a long string, but it still happens. So here’s a nice thing to know. You can split them over multiple lines without need the + operator and an Environment.NewLine call. What you need is a verbatim string literal. Those start with an @:

But […]

Read More

Running ASP.NET (not Core) from NPM

I’m currently working on a NodeJS project that makes HTTP calls to an ASP.NET (4.5.1) application. When running locally, I also want to make these calls to my local ASP.NET application. Sometimes, however, I don’t want to start up Visual Studio, open the project, compile, and run. Seeing as this is not ASP.NET Core, I […]

Read More

Autofac, Web API and filters

A short post with a small, useful tip. It’s mainly for my future self, but may be good to know for you too. If you’re using ASP.NET Web API, you might have controllers that look like this:

Two things can make your code cleaner here: First, use Autofac, you’ll greaty benefit Use the IAutofacExceptionFilter […]

Read More