A review of "Customizing ASP.NET Core 6.0, Second edition" by Jürgen Gutsch (@sharpcms) @PacktPub

I finished reading Jürgen's new book this week-end. Here are my key takeaways, the good, the bad and the ugly.

Although the book is titled Customizing ASP.NET Core 6.0, it also addresses content from ASP.NET Core 3, 3.1 and 5.0.


My key takeaways from the book

One of the biggest benefit I get from reading books and blog posts are eye-openers or a raised awareness of "what's out there". Jürgen gave me some 'aha's throughout his book:


Cmder

Cmder is a really nice console emulator software package, delivered as a portable distribution ready for you to bring with you, if you so desire!


A chain of commands

This little terminal nugget:

dotnet new <project type> -n <name> && cd <name> && code -r .

e.g.

dotnet new mvc -n MvcSample && cd MvcSample && code -r .

...translates into creating a new Model-View-Controller project named MvcSample in a new MvcSample directory (you can override this with the -o <output folder> flag), changing into the new MvcSample directory and then loading the directory into Visual Studio Code, reusing the previous instance of the editor.


Additional identity providers

ASP.NET Core Identity now offers individualb2callowing your users to use their preferred social, enterprise, or local account identities to get single sign-on access to your applications and APIs.


There's an aspnet-codegenerator tool

After installing the tool with dotnet tool install -g dotnet-aspnet-codegenerator and adding Microsoft.VisualStudio.Web.CodeGeneration.Design to your project, you can use it to generate areas, controllers, identity views, Entity Framework CRUD razor pages and views.


GenFu's a quite capable test data generation library

Its GitHub page explains what it does quite nicely:

Let's say you have a Person class like so:

class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Title { get; set; }
    public int Age { get; set; }
    public int NumberOfKids { get; set; }
	
	private string _middleName;
	public void SetMiddleName(string name){ _middleName = name; }
}

And you want a new instance of Person. With GenFu, you just do this:

var person = A.New<Person>();

Tada! Your person is now filled with all the data you could ever dream of!

For multiple entries, ask for a list:

var people = A.ListOf<Person>();

Handy!


Building tag helpers is easy!

I hadn't quite realize how easy it was to build your custom tag helper (often having resorted into building partial views/components for common concerns instead).

Also, there are plenty of packs out there already, including this one (no, jQuery isn't dead yet 😆).


The good, the bad and the ugly

Reading this book will introduce you to a number of concepts you might not previously be aware of. Reading it from start to finish might annoy you due to repeated content. However, jumping back and forth through the book might leave you in an incomplete project state. Luckily, the author has provided you with a complete source code repository on GitHub, which you can use as a cross-reference.


The good

If - after going through the below list - there are multiple topics that you want to learn more about, this book might be for you.

  • It teaches you how to customize logging, e.g. by plugging in a third-party logging provider.

  • It explains how to use typed configurations to load configuration sections into plain objects. It also describes how to use .ini files and get an increased understanding of configuration layers (e.g. environment variables overriding configuration files).

  • Using a third-party dependency injection container.

  • Working with certificates.

  • Working with Nginx and Apache as reverse proxies.

  • Working with / building background (non-HTTP) services.

  • Walkthrough of the middleware workflow.

  • Introduces health checks for when you want your application play nice with container orchestrators such as Kubernetes.

  • Working with EF Core, including updating your database with migrations.

  • Using the aspnet-codegenerator tool to scaffold authentication views.

  • Integrating IdentityManager2 into your solution.

  • Extending the formats that your controllers can consume and produce, including accepting and outputting blocks of CSV formatted data and dealing with the vCard format.

  • Introduction to API testing with Postman.

  • Dealing with cross-cutting concerns through Action Filters.

  • Caching data - static files, controller outputs, service/provider outputs and caching of partial views.


The bad and the ugly

The following detracted from the value I got out of reading this book:

  • It features a lot of repeated content, e.g. architecture schemas and each chapter's Technical requirements. It also mentions - no less than 6 times - that Microsoft introduced" the minimal API approach" in .NET Core 6.

  • I'm not particularly happy with the order of which code is introduced - usages are introduced before their dependencies leading to a series of incomplete code steps (which make me question whether I've followed the example correctly), before you finally end up in a compiling state.

  • Another point of order, you'll notice warnings to "Be sure that you are in the product directory before you execute the preceding command" (my emphasis).


Should I buy the book?

See the listing in The good.

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints