Things I’ve Learnt This Week (12th March)

Week 7 of my series, sharing things I’ve learnt, read, watched and listened to, in the pursuit of expanding my knowledge about software development.

Things I’ve Blogged

Things I’ve Learnt

ASP.NET Core MsBuild is Quicker than Project.json

It seems that the build time for the ASP.NET Core framework is nearly halved after moving back to csproj and MsBuild. Reduced down to approx. 28 mins from 52 mins. Read the tweet here

Live Unit Testing in Visual Studio 2017

It was a little disappointing to learn that the new live unit testing feature is not supporting .NET Core projects at launch. Looks like I’ll have to wait a while to try it since most of my projects are .NET Core at the moment.

Registering a Dependency with a non injectable property using Microsoft.Extensions.DependencyInjection

I was looking at an ASP.NET Core project which was using StructureMap to enable some more advanced service registrations that the built in Microsoft DependencyInjection package allowed. However, after looking through, I only found a few that I wasn’t sure how to register with the built in DI container. The project had a StructureMap registration like this:

c.For<DataValidator>().Transient().Use(() => new DataValidator(DataSource.DefaultData));

The DataSource.DefaultData is a static method in this case. After looking at the IServiceCollection methods, it seems the following line works with the default container to achieve the required result:

services.TryAdd(new ServiceDescriptor(typeof(DataValidator), p => new DataValidator(DataSource.DefaultData), ServiceLifetime.Transient)); 

Things I’ve Read

Things I’ve Listened To

Things I’ve Watched

Tools

One thought on “Things I’ve Learnt This Week (12th March)

Leave a Reply

Your email address will not be published. Required fields are marked *