.NET Standard Version Compatibility and Coding with WebSockets

On yesterday’s live stream, I learned a LOT about coding with websockets and answered a question about building .NET libraries for .NET Standard and older versions of .NET Framework.

I started by adding a page to the LiveStream wiki with my current speaking schedule.  I have a local user-group presentation coming up in January, and a few Microsoft events on the schedule.  As my schedule is populated with other events, I will update this page.  I will try to live-stream any event that I am at… but some are going to be more accessible to streaming than others.. I’m looking at you MVP Summit.

Next up was a question from Chris about building a library that is .NET Standard 2.0 compatible, but also compatible with older versions of .NET Framework, going back as far as .NET 4.5.  This is a tricky problem, as .NET Standard 2.0 is not supported on .NET 4.5, so how should you build it?  The answer is to build a NuGet package with two projects in it:

  • The first project should be an old-style Portable Class Library (PCL) that supports the frameworks you would like to target.  If you don’t want a PCL, you could also build individual class libraries that target each framework.. but that might be a LOT more work than you want.
  • The second project should target .NET Standard 2.0.  This standard will be supported for years to come.  You can find a great video of me explaining .NET Standard 2.0 and .NET Core 2.0 at the DevIntersection event on Channel 9:

Notice the red shirt in that video…  yea, I figure if another ASP.NET program manager can wear a red-shirt and advance in this company, it might be a good luck charm for me too.  🙂

We then started looking at the Rundown project.  There was a great pull-request submitted by John Bundgaard that cleaned up my simple MixerService, and used websockets to maintain a connection and receive immediate updates.  I REALLY like this approach, as it doesn’t use a timer to fetch updates, but instead keeps the socket open and listens for updates while the application is running.  We reviewed the code John submitted, and happily merged it into the application.  Thank you John for your contribution!

One of the features John included from his implementation of the MixerService, was the ability to monitor the Viewer count on Mixer.  This inspired me, and we started extending the TwitchService in our project to support capturing the Viewer count on Twitch.  With these two metrics acquired, I wrote a simple ViewersController to output the current number of Viewers. We’ll clean that up and make it fancier before implementing it in the stream’s video layout.

Next up: Saturday we will be live coding again, but joined by a guest pair-programmer: Iris Classon!  We’ll talk about live-coding on the web, work on a project together, and answer your questions then.  I hope you join us Saturday at 10am ET, 3pm UTC.