Roundup #71: C# Source Generators, MsQuic, CoreBoy, Channels

Introducing C# Source Generators

We’re pleased to introduce the first preview of Source Generators, a new C# compiler feature that lets C# developers inspect user code and generate new C# source files that can be added to a compilation. This is done via a new kind of component that we’re calling a Source Generator.

Link: https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/

MsQuic is Open Source

Microsoft is open sourcing our QUIC library, MsQuic, on GitHub under an MIT license. MsQuic is a cross-platform, general-purpose library that implements the QUIC transport protocol. QUIC is being standardized by the Internet Engineering Task Force (IETF). MsQuic is a client and server solution optimized for multiple usage patterns and is used by multiple Microsoft products and services. MsQuic is currently in preview and supports Windows and Linux.

Link: https://techcommunity.microsoft.com/t5/networking-blog/msquic-is-open-source/ba-p/1345441

CoreBoy

Link: https://github.com/davidwhitney/CoreBoy

Working with Channels in .NET

Channels enable a producer to safely pass data over to a consumer along with the appropriate notifications in both directions.

In this episode, Stephen Toub chats with Rich about the what, why and how of using the System.Threadding.Channels library. They walk us through a simple demo of using channels and also discuss the various strategies at our disposal.

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

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Migrating to ASP.NET Core

Migrating to ASP.NET Core

In the quest to migrate to .NET Core, the first step at the time (a couple of years ago) was to start migrating to ASP.NET Core from using Katana (Owin). This seemed like a logical first step as ASP.NET Core 2.x could run on .NET Framework as well as .NET Core. Ultimately this was a good first step in our migration.

ASP.NET Core 3.x is only supported on .NET Core 3.0 because it targets netstandard2.1.

.NET Framework only supports netstandard2.0 and will never support netstandard2.1

This makes it much more challenging to migrate because my recommendation is to get your application 100% compatible with netstandard2.0. If you do this, then you’ll be compatible with .NET Core 2.1.

Once you’re compatible with .NET Core 2.1 you can then can start running your applications on .NET Core 2.1 and from there, you can then migrate to .NET Core 3.x.

Migrating from .NET Framework to .NET Core

This blog post is in a series about migrating from .NET Framework to .NET Core.

Katana (OWIN)

Our web application was using the Katana Project and was self hosted using HttpListener. It was not using IIS.

This made our migration much simpler in some aspects because Katana really feels like a precursor to ASP.NET Core. Much of the same concepts exists such as the Startup and Middleware.

I’ve previously blogged about Migrating from Katana to ASP.NET Core. The general gist for migration is to implement any custom middleware you have with Katana over to ASP.NET Core. It’s really straight forward to do so and should feel natural. Most of the types are even named the same or very close to the same.

Web API

If you’re using ASP.NET Web API my biggest recommendation is to use the Compatibility Shim package.

This will save a bit of work as it adds functionality to ASP.NET Core to that was available in Web API. For example, it adds an ApiController type so you don’t need to update all your controllers to reflect the new ASP.NET Core Controller type.

Check out the official docs on the compatibility shim and what it provides and how to use it.

MVC

I don’t have much experience migrating MVC, however, I have used both ASP.NET MVC 5 and ASP.NET Core MVC and it doesn’t feel all that different. All the same, types (by name) exist such as Controller, ActionResult, etc.

Razor is still the same and so are layout files and the _ViewStart.cshtml.

Just like migrating Web API, you will need to create an ASP.NET Core application with the correct Startup class, and add/configure the MVC.

Check out the official docs on migrating from ASP.NET MVC

Migrating to ASP.NET Core Recommendation

My recommendation is to migrate to ASP.NET Core 2.1 and run it on .NET Framework 4.8.

The long term goal is to be running the latest ASP.NET Core on .NET Core. However, in order to migrate to ASP.NET Core, you want to be able to still run your application, which requires .NET Framework.

Do not worry about all your other dependencies yet, we will cover that in another post.

Useful Links

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Roundup #70: Coyote, DetectDuplicates, YARP, .NET 5, Lambda?

Coyote: Making it easier for developers to build reliable asynchronous software

For developers, writing bug-free software that doesn’t crash is getting difficult in an increasingly competitive world where software needs to ship before it becomes obsolete. This challenge is especially apparent with online cloud services, which are often dictated by aggressive shipping deadlines. Cloud services are distributed programs comprising multiple back-end systems that continuously exchange asynchronous signals while responding to incoming web requests. They are complex by nature, hard to get right, and require protection from failures that could jeopardize client data or halt key services.

Link https://www.microsoft.com/en-us/research/blog/coyote-making-it-easier-for-developers-to-build-reliable-asynchronous-software/

DetectDuplicates

A .NET Global tool that scans csproj files for duplicate package references

Link: https://github.com/jchannon/DetectDuplicates

YARP project (Reverse Proxy)

YARP (which stands for “YARP: A Reverse Proxy”) is a project to create a reverse proxy server. We found a bunch of internal teams at Microsoft who were either building a reverse proxy for their service or had been asking about APIs and tech for building one, so we decided to get them all together to work on a common solution, this project.

Link: https://github.com/microsoft/reverse-proxy

The Most Exciting Promise of .NET 5

It’s hard to believe that .NET only came out in 2002. There are so many versions of the framework, rapidly changing the places a C# developer could create and support. The entire ecosystem just turned 18, and it has been confusing at times with versioning. I fell in love with how powerful the platform was, but often, choosing to upgrade to the latest major or minor version proved difficult. How much actual value would I get from upgrading?

Link: https://developer.okta.com/blog/2020/04/17/most-exciting-promise-dotnet-5

Lambda? You Keep Using that Letter – Kevlin Henney

Lambdas. All the cool kid languages have them. But does ‘lambda’ mean what C#, Java, Python, C++, etc. mean by ‘lambda’? Where did lambdas come from? What were they originally for? What is their relationship to data abstraction?

In this session we will into the history, the syntax and the uses of lambdas and the way in which lambda constructs in various languages do (or do not) match the original construct introduced in lambda calculus.

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

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.