.NET
“Stop Using Async Await in .NET to Save Threads” | Code Cop #018 (via Nick Chapsas)
- Avoid using List<object> unless you have a very good reason to do so.
- for and foreach are essentially equivalent in modern .NET
- Use try–catch when something could be thrown by something you don’t control (e.g., Base Class Library). Yes, there’s overhead of handling exceptions; however, those continue to be optimized. Your goal should be to have predictable flow in your code.
- There are niche cases why you wouldn’t use async/await, and you need to clearly understand why you’re opting out of the usual pattern.
- The using construct compiles down into a try-finally block with a call to .Dispose().
Swagger is Going Away in .NET 9! (via Nick Chapsas)
- Swashbuckle is being removed in .NET 9 as a built-in package. You can still get it from NuGet.
- The issue is that Swashbuckle is no longer being maintained. (However, as of the video’s posting, it’s now active again.) There’s also NSwag, which is actively maintained.
- Microsoft will generate OpenAPI documents (i.e., JSON files), but there won’t be a way to visualize it like Swagger does.
- As expected, the third-party tools now have to decide whether they continue their efforts and compete with Microsoft.
- The replacement package that will ship with .NET Core is Microsoft.AspNetCore.OpenApi.
- The video shows using scalar (an open-source alternative to Swagger) to render a page based on the OpenAPI document .NET generates.