Skip to content

Coding Practice

Generate Code Into Separate Files With the T4.FileManager

When we generate code with T4, we end up with one single output file per template. That works if we only generate one HTML page or a single class. But when we want to generate multiple classes, the single output file is annoying. We never would let the developers write code that way; therefore, we should not let the automation get away with it either. Let us look at a solution to that problem.

Automate Code Generation With T4 Templates

After exploring the theoretical side of an automation project over the last few weeks, it is now time to get our hands dirty and write some code. There are many options for code generation, but I prefer the T4 templates. We have been using them for years and they are so stable that they form an excellent basis for our automation project.

Consistency Through Standardisation

Last week we elaborated on the different phases we need for a successful automation project. Today we explore the phase of standardisation in more depth.

In our process of Standardisation, Simplification and Automation we are in the phase of Standardisation

A nice side effect of the standardisation is that we get a more consistent output. Instead of the many different ways of doing things, we end up with a single approach and that by itself will reduce the inconsistencies.

Standardise, Simplify, Automate – In That Order!

There are not many topics in which success and failure are that close together than in an automation project. It does not matter if you automate a process or code generation – it is a small misstep to turn a possible success into a definitive failure. To change the odds to our favour, we should split our automation project into three distinct phases:

Our process starts with Standardisation, followed by Simplification, and ends with Automation

While everyone has their own ideas what could go into these phases, let us take the time to define them so that we have a common base of understanding.

Helpful Improvements in NDepend v2023.2

This year marks a decade since I started to use NDepend to assess the quality of .Net projects. NDepend got much better over the years, and as far as I can tell, it is still the most flexible and versatile tool in this space. After using the current version for the last three months, it is about time to give NDepend some space in this blog.

How a Little Environment Variable Can Break Your Integration Tests in ReSharper & Rider

Last week we run into a strange problem with our integration tests. On some developer machines everything worked fine, while other machines got errors like this one:

System.InvalidOperationException : Cannot resolve scoped service 'my.application.IOrderRepository' from root provider. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)

My Tool List of 2024

After 6 years it is time for an update of my tool list. At first, I thought that there are not that many changes, but after reinstalling my laptop I noticed that there are a few new entries that I would not want to miss.

Do you know a tool that is not on this list and that you find is a must-have? Please leave a comment with a link so that I can try it.