Week 3 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 Learned
Dependency Injection in Middleware
An important thing to consider when building custom Middleware in ASP.NET Core – If you are injecting a dependency into the constructor of your Middleware it may have unwanted effects if that dependency is expected to be a scoped/transient resource. The Middleware is constructed once for the app lifetime during Startup and not recreated for every request. If you want a transient/scoped dependency, inject it into the Invoke method’s parameters which is called once per request and therefore will give you the correctly scoped instance of your dependency every time.
Dependency Injection Lifetime Fun
A little long for this weekly post, I wrote up a dedicated post this week about some “fun” I had tracking down a range of errors we were seeing in some code this week. Spoiler alert… scoped lifetime dependencies inside a singleton lifetime registration = not good!
I also published a post this week entitled “Migrating from .NET Framework to .NET Core” which describes the process I followed to move an ASP.NET Core application from the full .NET framework onto .NET Core, enabling cross-platform development.
Things I’ve Read
In no particular order here’s some of the blogs and posts that I’ve read this week.
- Scaling Git (and some back story) by Brian Harry – An interesting read on Microsoft moving their Windows code-base over to Git source control.
- Boxing and Unboxing (C# Programming Guide) – Every now and again I like to dig into the deeper C# topics to remind myself of things and extend my knowledge.
- Boxing Nullable Types (C# Programming Guide)
- Anti-Forgery Tokens and ASP.NET Core APIs by K. Scott Allen – A useful read as this might be relevant to some API endpoints we expose in allReady.
- Dependency Injection in ASP.NET Core – I needed to double check something related to an issue I was having and this documentation helped confirm my suspicions.
- (ASP).NET Core Dependecy Injection: Disposing by Pawel Gerr
- A Non-trivial Example Of Mediatr Usage by Bobby Johnson
- Announcing Continuous Delivery Tools for Visual Studio 2017 – This looks pretty cool. Would be great it you could integrate other build and deploy systems running internally into VS as well.
- “I Don’t Trust Anything That We Didn’t Build” by Matthew Jones – I spent a lot of time reading the great content by Matthew Jones on a variety of topics.
- Learn or Die: Warding Off My Coding Career’s Eventual Obsolescence by Matthew Jones
- How To Become A Tech Conference Speaker by Matthew Jones – As I work on building up my own technical speaking, posts like this are a great inspiration and offer encouragement.
- Inside the Mind of the Tech Conference Speaker by Matthew Jones
- Factory Method – The Daily Design Pattern by Matthew Jones
- C#7: Better Performance with Ref Locals, and Ref and Async Returns by Jeff Yates – I’m less excited about these new C# 7 features as I can’t see me using them much in my daily code. Still worth a read to see what’s coming.
- Generalized async return types
- Serverless C# on AWS Lambda (pt. 1) by Ryan Stelly – I’m keen to play with Lambda’s at some point soon, as well as compare them to Azure Functions, which I’ve also not had the chance to use yet.
- What do you mean by “Event-Driven”? by Martin Fowler
- Trying out “dotnet new” template updates and csproj with VS2017 by Scott Hanselman
- Ship Small Diffs by Dan McKinley
Things I’ve Listened To
- Coding Blocks – Clean Code – How to Write Classes the Right Way
- .NET Rocks – Chatbots with Galiya Warrier
- .NET Rocks – Xamarin MVVM apps with Gill Cleeren
- .NET Rocks – Ops and Operability with Dan North
- RunAsRadio – Scaling in the Cloud with Corey Sanders
Things I’ve Watched
- NDC Sydney – Diving into Elasticsearch with .NET – Russ Cam – We use ElasticSearch quite extensively on project at work and I was looking for some good videos about it. I found this a nice code-based overview of the functionality available in ElasticSearch when working with the .NET libraries.
- On .NET – Docker – New .NET Core tooling – Hard to follow all of the demos as the highest quality available to me was medium but interesting to see some of the tooling around Docker and the new csproj format in action.
- ASP.NET Monsters #92: Saving CPU Cycles with Static Resource Hashes – A really interesting look at some clever stuff you can do using ASP.NET Core.
- ChangemakerStudios – Papercut – A useful local SMTP receiver for testing email in your code on localhost. This week I was adding some email functionality to one of our services and I wanted to test the flow locally in development. This tool was really easy to use and worked perfectly for my requirements.