What’s next for the .NET Pulse Newsletter? You may have noticed it has been a while since the last .NET Pulse issue. Over the past year, a lot has changed for me: I stepped into a Tech Lead role and had a very active sports season, completing three triathlons and a trail run.
Oleg Kyrylchuk 🇺🇦
@okyrylchuk.dev
.NET Enthusiast Newsletter https://okyrylchuk.dev Help for Ukraine http://ko-fi.com/okyrylchuk or http://paypal.me/okyrylchuk
C# 14 introduces user-defined compound assignment operators. In previous versions, you could not overload the += operator. C# 14 allows user types to customize the behavior of compound assignment operators in a way that the target of the assignment is modified in-place.
C# 14 in the preview introduces the field keyword. It lets you write a property accessor body without declaring an explicit backing field. The compiler will replace the field keyword with a backing field. What do you think about this improvement?
C# 14 in the preview introduces partial constructors and events. They must include exactly one defining declaration and one implementing declaration. The implementation declaration of a partial event must include add and remove accessors.
C# 14 in the preview allows an unbound generic type as an argument to nameof. For example, nameof(List<>) returns List. Previously, you could pass only closed generic types, such as List<int>, to return List.
C# 14 in the preview allows the null conditional member access operator on the left-hand side of an assignment. Previously, you had to check if the customer was null before assigning the order. In C# 14, the GetCurrentOrder method is not called if the customer is null.
C# 14 in the preview introduces extension members There is a new extension keyword that lets you define extension blocks for extension properties, methods, and operators This means you can group related extension members, enhancing code readability and maintainability Do you like the new feature?
🎉 I'm incredibly honored to receive the Microsoft Most Valuable Professional award for the 4th time in the Developer Technologies category! I’m looking forward to another exciting year in the MVP program, continuing to learn, share, and grow with this amazing community.
C# 14 in the preview allows the null conditional member access operator on the left-hand side of an assignment. Previously, you had to check if the customer was null before assigning the order. In C# 14, the GetCurrentOrder method is not called if the customer is null.
C# 14 in the preview allows an unbound generic type as an argument to nameof. For example, nameof(List<>) returns List. Previously, you could pass only closed generic types, such as List<int>, to return List.
Since .NET 5, ASP NET Core has built-in support for the Swashbuckle project (Swagger). ASP NET Core 9 removes Swashbuckle from the template. However, the .NET team added support for OpenAPI document generation. The AddOpenApi method registers the required dependencies.
C# 14 in the preview introduces the field keyword. It lets you write a property accessor body without declaring an explicit backing field. The compiler will replace the field keyword with a backing field. What do you think about this improvement?
#1 How to Avoid Common EF Core Performance Pitfalls Entity Framework Core is one of the most popular ORMs in the .NET ecosystem, for good reason. It abstracts away the complexity of working with databases, allowing developers to focus on business logic rather than SQL queries.
System.Text.Json 9 introduces respecting required constructor parameters. You can control the behavior with the new RespectRequiredConstructorParameters JSON serialization option. If it's true, the serializer throws the JsonException for missing required properties.
When should you implement API versioning? The short answer is that as soon as your API is consumed by more than just yourself. This Friday, I'll show you how to manage API Versioning Like A Pro in ASP NET Core. Don’t miss out! Subscribe now! The link is in the comments.
“Fan out” refers to distributing or spreading functionality or data flow from a single point to multiple points. In messaging systems, it means to send one message to many recipients. Check my post to learn how easily to fan out HTTP requests in .NET. Link in the comments.
.NET 9 introduces the new LINQ method CountBy. It allows for calculating the frequency of a key. This improvement looks nice. What do you think?
.NET 9 introduces a new GUID implementation based on timestamp and random. It makes GUID sequential, which makes it more suitable for relationship databases. Also, GUID gets the Version property to check the version of the created GUID.
How do you check if a list is not null and has elements? There are several ways to do it: 1. Classic way 2. List.Count way 3. Enumerable.Any way 4. Pattern matching way Which one do you prefer — or do you use a different approach? Let me know in the comments! 👇
How to control the delay in the Task.Delay method in tests? You can pass the TimeProvider to the Task.Delay method since .NET 8. The TimeProvider will interpret the delay. You can use FakeTimeProvider to control the delay in tests.
C# Tip 💡 Use string.Join method to concatenate elements of a collection into a single string, inserting a specified separator between each element. ✔ More readable — No loops ✔ Better performance — Avoids unnecessary string allocations ✔ Less error-prone — No need to trim the last separator
The OrderedDictionary type has existed in .NET since an early age. .NET 9 introduces the generic counterpart. It creates a dictionary where the order of key-value pairs can be maintained. Have you ever used OrderedDictionary?
1. This Friday, .NET Pulse is diving into something we’ve all been waiting for — the Azure Service Bus Emulator! For years, testing Azure Service Bus locally meant relying on cloud instances, costly workarounds, or incomplete mocks. But not anymore!
I like Refit. Refit is a .NET library designed to make interacting with RESTful APIs easy and efficient. With features like type safety, easy setup, and extensibility, Refit can save you time and reduce boilerplate code in your projects. Check out my post on how to start with Refit.
ASP NET Core 9 allows the disabling of HTTP metrics and the non-recording of values for specific endpoints and requests. For instance, automated systems check the Health endpoint, so recording metrics for it is not particularly helpful.
System.Text.Json serializer uses reflections for serialization and deserialization. Reflection is slow. .NET 5, alongside C# 9, introduces source generators. It allows the generation of code during compilation.
Pattern matching is handy in C#. The Type pattern tests the variable to see if it matches a given type. The Declaration pattern checks if the variable matches the type and assigns the result to a declared variable. Do you use these patterns?
My favorite C# 12 feature: collection expressions! 🚀 A terse way to initialize collections, working with arrays, Span<T>, and more. The .. spread operator lets you inline collections easily. Do you like it?
.NET 10 Preview 1 is now available! 🤓 Follow me if you want to be updated with new .NET 10 features. If you want more detailed .NET 10 features, consider subscribing to my newsletter! Link in the comments.
.NET 9 introduces CreateUnboundedPrioritized in System.Threading.Channels! Unlike FIFO channels, it dequeues the most prioritized element using Comparer<T>.Default or a custom IComparer<T> first. Do you use channels? For what use cases?