The .NET Stacks #9: Project Coyote, new Razor editor, and more!

We discuss Project Coyote, a new Visual Studio Razor editor, and more!

Dave Brock
Dave Brock

So, what do you think? I changed newsletter providers and got a new look (thanks to @comfycoder for the logo help). I hope you like it. It works on my machine, and I hope it works on yours too. 😎

Any suggestions? Hit me up on Twitter or just reply to this e-mail. I’m all ears on what content you’d like—I want to make this the best part of your Monday!

This week we’re talking about debugging async with Coyote, an exciting new Razor editor in Visual Studio, a fun look at unit testing, and more!

Debug async issues faster with Coyote

Isn’t async programming fun? It’s so much fun, you can probably relate to this. (If you’ve spent months on a single concurrency issue, it might also make you cry.)

All jokes aside, it’s a concurrent world and we just live in it. Our customers demand it. In this microservice-friendly, cloud-first world, we want things fast and efficient at the lowest cost possible. In the cloud, minimizing cost requires high throughput, which requires high concurrency. If you haven’t pulled your hair out from a concurrency/threading issue, to that I say: welcome to our field. I hope you had a nice graduation party.

We know this is hard, and that’s why we rely on the .NET framework to handle most of the magic for us. With the Task Parallel Library (TPL) and async/await, we don’t have to worry about thread scheduling, state management, or other hard low-level details.

However, we also get flexibility with APIs like Task.Run that give us the power to queue work—if we don’t know exactly what we’re doing, we can get in loads of trouble. Even with high code coverage, powerful integration testing, and stress testing, we still know we’re not too far from a concurrency issue that will cost our customers (and our employers) tons of time and money.

Meet Coyote, a set of tools that help you find these seemingly impossible-to-reproduce bugs quicker. (It is an evolution of the P# project, and is moving out of research mode.)

How does this work? After you write code that uses the Coyote programming model—the familiar task-based model in in preview—you can run coyote test, where the magic begins. When you run this, Coyote manages task scheduling and explores all the complexities of your code. Coyote runs tests repeatedly with “different scheduling choices” each time. If a bug is found, Coyote reports a reproducible bug trace, which can be replayed until you find the bug.

Coyote has been put through its paces for various Azure services and promises integration with unit testing frameworks and minimal overhead. Is it worth it for internal CRUD apps? Maybe not. But if you are operating at tremendous scale where concurrency issues keep you up at night, it might be a game-changer.

There’s so much to take in! Check out the resources for more details on Project Coyote.

New Razor editor for Visual Studio in preview

It seems like we’re constantly getting news of a new Visual Studio preview feature, and this week is no exception. If you download Visual Studio 2019 16.7 Preview 4 (got all that?) you can use a brand new Razor editor to assist your local development with Blazor, MVC, and Razor Pages.

Most of us know Razor but if you don’t: it’s a templating language (using HTML and, most frequently, C#) you use to define how you dynamically render content in your ASP.NET app. With Blazor, you can reuse UI components using .razor files. Razor in Visual Studio comes with IntelliSense, completions, and the like. Why a new editor, then?

Today, Visual Studio does a lot of tricks behind the scenes with projection buffers for the different languages it supports. For example, if you have C# and HTML in a Razor file, Visual Studio reads the Razor file from disk, sends the code to a Razor buffer, a C# buffer, and an HTML buffer. Finally, each buffer uses its own independent language service for each language you use. Oof.

Why should you care? If you’ve signed a lifetime contract to use Visual Studio and you’re a team of one, fine—but if you want extensibility with Codespaces or Live Share in VS, you’re in trouble. All these dependencies require a lot of work to coordinate and can hinder the speed of future improvements.

To address this, Microsoft has been working on a Razor Language Server that implements the features you know and love through a common protocol. Wherever the extension exists (VS, VS Code, wherever), it coordinates with the Razor Language Server.

This solution is currently used for Razor support in VS Code, and will be used for Codespaces and LiveShare for Visual Studio. And now, you can try the VS implementation today (in preview). It has some rough edges, but I look forward to see how it performs. I do know Razor mostly works well but can exhibit some inconsistent performance. Will this help?

🌎 Last week in the .NET world

I’m trying a new format this week so you can sift through the links easier.

🔥 The Top 3

📢 Announcements

📅 Community and events

😎 Blazor

🚀 .NET Core

⛅ The cloud

📔 Languages

🔧 Tools

📱 Xamarin

🎤 Podcasts

🎥 Videos

.NET Stacks