Here are some of the best .NET, C# and ASP NET posts from this week.
This Weeks Articles
By Khalid Abuhakmeh
You may have heard about a new feature in .NET 5 called Source Generators. Developers can now generate dynamic code at compile time that .NET will weave into a consuming assembly. The possibilities are endless and will most likely have a profound impact on how we write applications and, ultimately, the performance we can expect from our apps. That said, getting started with source generators can seem a bit opaque. In this post, we’ll start with nothing and go through creating a source generator ready solution.
By Andrea Chiarelli
.NET comes with several project templates that help to quickly scaffold applications in different contexts. You may need to create your own project template in specific contexts. The article explains how you can create your own project template to use with .NET CLI and Visual Studio.
By Mark Seemann
In 2020 I developed a sizeable code base for an online restaurant REST API. In the spirit of outside-in TDD, I found it best to test the HTTP behaviour of the API by actually interacting with it via HTTP. Sometimes ASP.NET offers more than one way to achieve the same end result. For example, to return 200 OK, you can use both OkObjectResult and ObjectResult. I don't want my tests to be coupled to such implementation details, so by testing an API via HTTP instead of using the ASP.NET object model, I decouple the two. You can easily self-host an ASP.NET web API and test it using an HttpClient. In this article, I'll show you how I went about it.
You Might Also Like
- Introduction to Test Driven Development (TDD) and AAA Testing using xUnit
- Writing decoupled code with MediatR: The Mediator Pattern
I post mostly about full stack .NET and Vue web development. To make sure that you don't miss out on any posts, please follow this blog and subscribe to my newsletter. If you found this post helpful, please like it and share it. You can also find me on Twitter.