从 Newtonsoft.Json 迁移到 System.Text.Json
System.Text.Json 是 .NET Core 3 及以上版本内置的 Json 序列化组件，刚推出的时候经常看到踩各种坑的吐槽，现在经过几个版本的迭代优化，提升了易用性，修复了各种问题，是时候考虑使用 System.Text.Json 了。本文将从使用层面来进行对比。 System.Text.Json 在默认情况下十分严格，避免进行任何猜测或解释，强调确定性行为。比如：字符串默认转义，默认不允许尾随逗号，默认不允许带引号的数字等，不允许单引号或者不带引号的属性名称和字符串值。 该库是为了实现性能和安全性而特意这样设计的。Newtonsoft.Json 默认情况下十分灵活。 关于性能，参考 Incerry 的性能测试：.NET性能系列文章二：Newtonsoft.Json vs. System.Text.Json ，如果打算使用 .NET 7 不妨考虑一下 System.Text.Json。
What is .NET, and why should you choose it?
.NET has changed a lot since we kicked off the fast-moving .NET open-source and cross-platform project. We’ve re-thought and refined the platform, adding new low-level capabilities designed for performance and safety, paired with higher-level productivity-focused features. Span
.NET February 2023 Updates – .NET 7.0.3, .NET 6.0.14
Today, we are releasing the .NET February 2023 Updates. These updates contain security and non-security improvements. Your app may be vulnerableif you have not deployed a recent .NET update.You can download 7.0.3and 6.0.14versions for Windows, macOS, and Linux, for x86, x64, Arm32, and Arm64...
Rebus in .NET - Service Bus Implementation
When working with distributed applications that need to asynchronously communicate with each other, the “Publish-Subscribe” pattern is very common. To avoid being tightly coupled to a message broker, such as RabbitMQ, we use an abstraction layer, known as a service bus. Rebus is one such service bus implementation for .NET that allows us to easily communicate asynchronously between services. This article makes use of Docker to run our message broker (RabbitMQ) server locally.
How to Add a BearerToken to an HttpClient Request
Often, in our daily routine, we have to deal with secure APIs and use a BearerToken to make HTTP requests. In this article, we are going to learn the correct way to add a BearerToken to an HttpClient request.
Working With Collections in .NET
When we develop software applications, we may need to create, store and manipulate groups of related objects. In this article, we will discuss the various ways in which we can perform such operations using different collections in .NET.
.NET December 2022 Updates – .NET 7.0.1, .NET 6.0.12, .NET Core 3.1.32
Today, we are releasing the .NET December 2022 Updates. These updates contain security and non-security improvements. Your app may be vulnerable if you have not deployed a recent .NET update. You can download 7.0.1, 6.0.12, and 3.1.32 versions for Windows, macOS, and Linux, for x86, x64, Arm32, and Arm64.
Schedule Jobs with Quartz.NET
Recurring, background tasks are widespread and very common when building applications. These tasks can be long-running or repetitive and we don’t want to run them in the foreground, as they could affect the user’s experience of the application. So instead we must schedule these jobs to run in the background somewhere. To achieve this in .NET, we can use the Quartz.NET library to manage the creation and scheduling of these jobs. This article makes use of Docker to run SQL Server server locally. Optionally a local install of SQL Server can be used.
Producer-Consumer Applications With .NET Channels
When building applications, usually we need to create long-running background tasks, that can be sent to one or more background processes. This is known as a producer/consumer pattern. For these scenarios, we need something more robust than a first-in, first-out queue, but we don’t need the complexity and infrastructure involved in a message broker such as RabbitMQ, which is where Channels comes in.
What’s new in the .NET MAUI Community Toolkit
November has been a busy time for the .NET MAUI Community toolkit with multiple releases featuring a ton of amazing new features (not to mention a long list of bug fixes). The latest releases have new Views, Layouts, Tizen support, .NET 7 support and so much more. This post will get you up to speed on all the new features.
Using Dynamic LINQ With System.Linq.Dynamic.Core Library
In most applications, we query data from a source, a database, for instance, and perform operations on that data. For this, we use can use LINQ. However, when we want to unlock more powerful features of the C# language, we use the System.Linq.Dynamic.Core library. In this article, we are going to learn about this library and its features through different use cases.
Stop using trivial Guard Clauses! Try this instead
Guard clauses, on the surface, sound like a great idea. They can reduce conditional complexity by exiting a method or function early. However, I find guard clauses used in the real world to be of little value. Often polluting application-level code for trivial preconditions. I will refactor some code to push those preconditions forcing the edge of your application so your domain focuses on real business concerns.
Announcing NuGet 6.4 - Signed, Central, Delivered
NuGet 6.4 is included in Visual Studio 2022 and .NET 7.0 out of the box. You can also download NuGet 6.4 for Windows, macOS, and Linux as a standalone executable. NuGet 6.4 is one of many releases in our .NET unification journey. Our NuGet tooling helps developers discover new .NET packages to use for their .NET applications, while making package management easier during your daily development.
.NET November 2022 Updates – .NET 6.0.11 and .NET Core 3.1.31
Today, we are releasing the .NET November 2022 Updates. These updates contain non-security improvements. Your app may be vulnerable if you have not deployed a recent .NET update. You can download 6.0.11 versions for Windows, macOS, and Linux, for x86, x64, Arm32, and Arm64.
.NET Framework November 2022 Security and Quality Rollup Updates
Today, we are releasing the November 2022 Security and Quality Rollup Updates for .NET Framework.
Announcing .NET Community Toolkit v8.1.0 Preview 1
We’re happy to announce Preview 1 of the upcoming .NET Community Toolkit 8.1 release! This first official preview includes several highly requested new features, bug fixes, and most importantly it includes massive performance improvements to the MVVM Toolkit source generators, to make the developer UX when using them even in very large solutions, better than ever!
.NET 7 Performance Improvements in .NET MAUI
When .NET MAUI reached GA, we had goals of improving upon Xamarin.Forms in startup time and application size. See last release’s Performance Improvements in .NET MAUI, to learn about the performance benefits of migrating from Xamarin.Android, Xamarin.iOS, or Xamarin.Forms to .NET 6+ and .NET MAUI.
Using WASM and WASI to run .NET 7 on a Raspberry PI Zero 2 W
WebAssembly (WASM) and WebAssembly System Interface (WASI) are opening new opportunities for developers. .NET developers became familiar with WASM when Blazor WebAssembly was released. Blazor WebAssembly runs client-side in the browser on a WebAssembly-based .NET runtime. WASI is bringing WASM out of the browser world by providing a system interface to run WebAssembly outside the web. It is a standard for how WASM modules interact with the host environment. This post will show you how to run .NET 7 on a Raspberry PI Zero 2 W using WASM and WASI.
How to Use Shouldly to Improve Unit Tests in .NET?
In this article, we are going to explore Shouldly. Shouldly is a library that improves the quality of our tests.
ASP.NET Core rate limiting middleware in .NET 7
Starting with .NET 7, ASP.NET Core includes a built-in rate limiting middleware, which can be used to rate limit web applications and APIs. In this blog post, we’ll take a look at how to configure and use the rate limiting middleware in ASP.NET Core.