Roundup #68: Binding Redirects, Combining Types as Effects to Describe an Application, Endpoint from multiple middleware, Clean Architecture

Here are the things that caught my eye recently in .NET.  I’d love to hear what you found most interesting this week.  Let me know in the comments or on Twitter.

Binding Redirects

You’re probably here because of an error like this:

Could not load file or assembly ‘System.<…>, Version=4.x.x.x, Culture=neutral, PublicKeyToken=<…>’ or one of its dependencies. The system cannot find the file specified.

And you likely saw a build warning like this:

warning MSB3277: Found conflicts between different versions of “System.<…>” that could not be resolved.

Whelp, you’re not alone. We’re thinking about starting a survivors group.

If someone starts a survivors group, I’m joining. I’ve spent a serious amount of time and head-scratching over binding redirects. Specifically around System.Net.Http. The answer in my case was using <AutoGenerateBindingRedirects>

Link: https://nickcraver.com/blog/2020/02/11/binding-redirects/

Combining Types as Effects to Describe an Application

I can only imagine the face I made the first time someone referred to the type of an application. Coming from a Delphi, .NET, and web background at the time, I assumed the type of an application was Web vs Desktop vs Command Line. What I came to understand was that types can be used to model effects which can then determine what your application does.

Reid pointed out this post he wrote after I posted the following tweet (and my typo of “ton”… oops). I highly recommend reading this as Reid points out something I’ve never really thought of before.

Link: https://medium.com/@reidev275/combining-types-as-effects-to-describe-an-application-5830a1c48c05

Creating an endpoint from multiple middleware in ASP.NET Core 3.x

In a recent post I discussed the changes to routing that come in ASP.NET Core 3.0, and how you can convert a “terminal” middleware to the new “endpoint” design. One question I’ve received is whether that removes the need for “branching” the pipeline, and if not, how can you achieve the same thing with endpoints?

This short post assumes that you’ve already read my post on converting a terminal middleware to endpoint routing, so if you haven’t already, take a look at that one first! I give a quick recap below, but I won’t go into details.

Link: https://andrewlock.net/creating-an-endpoint-from-multiple-middleware-in-aspnetcore-3/

The Clean Architecture – Ian Cooper

What is the clean architecture and how you would build one in .NET? Recently Bob Martin has categorized a set of architectures, including hexagonal architecture, onion architecture and screaming architecture as ‘the clean architecture’ – a layered architecture of concentric circles with a strong emphasis on separation of concerns. This architecture has become popular because of its amenability to modification as an evolutionary architecture and its support for practices such as TDD. In this presentation we will discuss the clean architecture and its benefits. More than that, in the bulk of the presentation, we will show you how to implement a clean architecture in .NET. From first steps to working code, we will show you the moves required to embrace this approach, and introduce you to some of the OSS libraries that can help you get there. All examples will be in .NET Core

Link: https://www.youtube.com/watch?v=SxJPQ5qXisw

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Roundup #67: Cert Expiration Check, Should I use MicroServices? StackOverflow Survey, gRPC-Web

Here are the things that caught my eye recently in .NET.  I’d love to hear what you found most interesting this week.  Let me know in the comments or on Twitter.

Certificate Expiration Check

I thought this was a pretty cool idea and an easy way to keep track of expiring certs.

Link: https://github.com/ardalis/CertExpirationCheck

Should I Use A Microservices Architecture?

Are you considering adopting a microservices architecture? Won’t it fix all your problems? Join me for a look into the realities of microservices!

Link: https://www.jamesmichaelhickey.com/microservices-architecture/

2020 Stack Overflow Developer Survey

Thank you for taking the 2020 Stack Overflow Developer Survey, the largest and most comprehensive survey of software developers (and anyone else who codes!) on Earth. 

Link: https://stackoverflow.az1.qualtrics.com/jfe/form/SV_eL0mFVwuo7KWeXP

A new experiment: Call .NET gRPC services from the browser with gRPC-Web

I’m excited to announce experimental support for gRPC-Web with .NET. gRPC-Web allows gRPC to be called from browser-based apps like JavaScript SPAs or Blazor WebAssembly apps.

gRPC-Web for .NET promises to bring many of gRPC’s great features to browser apps:

Strongly-typed code-generated clients
Compact Protobuf messages
Server streaming

Link: https://devblogs.microsoft.com/aspnet/grpc-web-experiment/

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Message Sender: Who Sent the Command/Event?

Message Sender

When handling a message, regardless if it’s a command or event, you often want to know who sent the message. Who was the message sender? Not the service, but the actual user who initiated it. If it’s a command then who invoked it. If it’s an event, who invoked the command that changed state within the system that created the event.

This post is in a series related to messaging. The overview is available in my Message Properties post.

Authorization

The most common reason for wanting to know who sent a message is to determine if they are authorized to perform whatever action is being done by a command. The same can apply for events and event handlers. The task of an event handler may be conditional on who caused the event in the first place.

SenderID

This can be as simple as including a SenderID along with your message data. A simple example based on other posts in this series:

The SenderID would represent a way for your server to identify who is sending the message. This could be a unique identifier of a user within the system.

ID Token

Another option is to include an ID Token.

ID Tokens are a similar idea but used mainly in token-based authentication. It provides a more performant way of accessing the user profile and access rights. Basically it’s a cached copy of the user profile that was generated when the user authenticated.

One concern here is if you are persisting messages for any length of time, and processing them later, you need to be aware that the ID Token may have expired and may no longer exist in the cache. ID Tokens generally have a lifetime and your message storage may not.

The benefit is access to authorization information that you may need when processing a message. Is the sender authorized to perform an action?

Message Sender

If you have any other ways you like to keep track of the sender, let me know in the comments or on Twitter.

Related Links

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.