Cost of method wrapper

Introduction What happens if a method is just a wrapper for another method? Is the extra jump optimized away by compiler? Does it take much time? I thought I’d look into this and measure a bit. With the different compilers, Jits and runtimes I thought it would be fun to see what happens. I’ll use a == operator… Read More »

Speeding up Unitys Vector in lists/dictionaries

Introduction With this post I am digging into some performance improvements for Unity 3D’s Vector2, Vector3, Vector4 and Quaternion. The short version is that they really need IEquatable<T>  and can benefit from a better GetHashCode() . I’m demonstrating this with example of how it severely decreased performance in my project. Adding IEquatable<T> has no side-effects, if is actually best… Read More »

Simple app.config appSettings deserializer (with tree structure)

There are many ways to read configuraiton files in .Net. Using ConfigurationManager you can easily read for example appSettings section. But usually I want this to be in managed code. The solution often suggested is to create separate sections with a varying degree of manual work, field mapping and xml readers. Many of the solutions also suggest that… Read More »

Automatic class generator for CsvHelper

CsvHelper helps in reading CSV files. But creating the model and mapper classes can be a bit time consuming. On this page you can generate the classes. Just fill inn the fields bellow with the header for your CSV file. It will generate the model and a mapper class. Code sample to use classes generated:

  Name: Header:… Read More »

IIS redirect HTTP to HTTPS but allow Let’s Encrypt

Let’s Encrypt makes it easy for everyone to use HTTPS. The Windows client letsencrypt-win-simple simplifies installing and updating certificate in IIS. Using IIS URL Rewrite function you can allow Let’s Encrypt certificate retrieval/renewal and redirect all visitors to HTTPS URL of site.


Template replacement engine

Using Regex as a template engine is an efficient way to replace strings in a template. Regex replace method supports executing a method upon match. We can populate a dictionary and make a lookup on all matches. This way we do the replacement in a single pass, rather than executing multiple .Replace(). Since dictionaries can be made case insensitive we have… Read More »

Norske fødselsnummer i C# / Norwegian national ID numbers in C#

Code to verify Norwegian national id number (fødselsnummer / personnummer) written in C#. Obeys 2013 standards as described in this Wikipedia article. Please let me know how if you find bugs / improvements. :)

(PS: This code is easy to test in LINQPad. Select C# Program, paste it in and hit run.)

Investigating Unity hang on second run (multi-threading)

Background he problem of Unity hangs on second run may have multiple causes and can sometimes be difficult to debug. When searching for an answer I see many with the same problem. I am therefore sharing a my debugging process in hope that it can help others solve their own problem. The problem Unity has had a problem… Read More »

C# Regex for verifying e-mails

Regex for matching e-mail in C#. Came across which has a horrible example, so ended up making my own loosely based on that. It leaves much to be desired, but will cover most use cases well enough.


ASP.Net 5 Identity Framework 3.0 manually adding users

Identity Framework 3 is in release candidate along with ASP.Net 5. The problem I set up a web project in ASP.Net 5 and created a controller for user import. It’s just some simple code that attempts to add multiple users. Adding a single user works great, but if I attempt to perform multiple operations in one go I… Read More »