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

Week 8 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

ASP.NET Core MVC Anatomy (Part 1) – AddMvcCore – Dissecting and understanding the internals of ASP.NET Core MVC. In this post I looked at what the AddMvcCore extension method to the IServicesCollection does.

ASP.NET Core Anatomy (Part 2) – AddMvc – Dissecting and understanding the internals of ASP.NET Core. In this post I looked at what the AddMvc extension method to the IServicesCollection does.

Things I’ve Learnt

Debugging ASP.NET Core with csproj

This is something I’ve been checking into from time to time. I’ve been a heavy user of the ability global.json gave us in VS 2015 to debug into ASP.NET Core assemblies. Especially to help with my current ASP.NET Core Anatomy series. With the move back to csproj in VS 2017 we no longer have a global.json file to identify the projects we want to load source from. This was touched on in the ASP.NET Community Standup this week. Damian Edwards confirmed they are hopefully working on a solution, but at the moment there is no easy way to do this. With some ceremony it might be possible since the ASP.NET team themselves need to do this to develop the product. I’d love to be able to get my hands on a fairly simple set of instructions to enable this again.

Things I’ve Read

Things I’ve Listened To

Things I’ve Watched

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