Category: .Net Core

Why Developers Don’t Write Unit Tests

When I started my career in software development 22 years ago this year, it seemed that unit testing adoption was rather patchy. Whether you wrote unit tests or not, depended upon the environment you worked in. So most developers only used to write unit tests if they worked on a project which mandated unit testing, […]

Nullable Reference Types

Previous Versions Previously in C#, references have been allowed to be null and they could be de-referenced without null checks. We would then get a NullReferenceException, this happens when we dereference a variable which is set to null. Sometimes we have nulls coming from other parts of the code, which we then discover later when […]

C# Expression Bodied Members

We first saw expression bodied members introduced in C# 6. This introduced the ability to take a single expression method and read-only property and reduce it to a more concise form. Functions For example a single line function can be reduced from this: To the following code below: Read-only Properties A read-only property can be […]

.Net Core – Testing Internal Methods

In the .Net Framework, the approach to unit testing internal methods or types was to add an InternalsVisibleTo attribute into the AssemblyInfo.cs file. For example look at the following line of code below: This all works fine in the .net Framework. However in .Net Core most of the settings in the AssemblyInfo file have moved […]