Best of .NETNovember 2024

  1. 1
    Article
    Avatar of milanjovanovicMilan Jovanović·2y

    Clean Architecture: The Missing Chapter

    Clean Architecture is about dependencies, not folders. Many developers mistakenly turn the Clean Architecture diagram into a project structure, but the focus should be on managing dependencies. Traditional layer-based organization scatters related components and creates maintenance challenges. Organizing code by feature or component helps achieve better dependency management and business focus. The post provides practical examples and best practices for implementing these principles in .NET, highlighting the importance of managing dependencies and keeping related code together.

  2. 2
    Article
    Avatar of freecodecampfreeCodeCamp·2y

    How to Benchmark Your Code in C#

    Learn how to benchmark and optimize your C# code using BenchmarkDotNet, a powerful library for accurate performance measurements. Discover why Stopwatch is not reliable for detailed benchmarking, understand key metrics like mean, error, and standard deviation, and explore how to measure memory allocation and garbage collection impacts. This guide also explains running benchmarks across different .NET frameworks and inputs for comprehensive performance insights.

  3. 3
    Article
    Avatar of devblogsDevBlogs·1y

    Next Generation Project Creation for .NET

    The new interactive CLI tool 'dotnet scaffold' has been released as a preview for scaffolding in ASP.NET Core projects. It provides an improved command line experience, allowing users to generate boilerplate code interactively. This post details the installation process, usage examples, and shows how to scaffold different components such as Razor Pages and Entity Framework models in ASP.NET Core 9 web apps. The tool aims to make project setup more straightforward and efficient.

  4. 4
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Stop Using AutoMapper in .NET

    The post discusses the drawbacks of using AutoMapper and other mapping libraries in .NET, advocating for manual mapping instead. It highlights issues such as the introduction of runtime errors, complexity, and debugging difficulties when using these libraries. The author suggests using simple extension methods for mapping and emphasizes the importance of maintaining control over the code. Alternatives like compile-time libraries are mentioned but manual mapping is preferred for its simplicity and reliability.

  5. 5
    Article
    Avatar of auth0Auth0·2y

    Authentication and Authorization Enhancements in .NET 9.0

    NET 9 includes various enhancements for authentication and authorization, focusing on cloud-native development and performance. Key features include support for Pushed Authorization Requests (PAR) to enhance security in OAuth 2.0 and OpenID Connect environments, simplified methods for adding custom OAuth/OIDC parameters, configuration flags for Windows Authentication under HTTP.sys, and methods to serialize authentication states in Blazor Web Apps. These updates aim to simplify developers' tasks, improve security, and reduce potential bugs.

  6. 6
    Article
    Avatar of dotnet.NET Blog·1y

    OpenAPI document generation in .NET 9

    ASP.NET Core in .NET 9 introduces built-in support for OpenAPI document generation, simplifying the process of documenting API endpoints. This feature supports both Minimal APIs and controller-based applications, and allows for customization via attributes and extension methods. Developers can generate OpenAPI documents at both runtime and build time, integrate metadata for better documentation, and use transformers for further customization.

  7. 7
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Everything New Added in .NET 9 with Examples

    Nick introduces various new features of .NET 9, focusing on practical implementations that developers will find useful. Key features include feature switching for managing feature flags, improvements in LINQ for simplified code, and hybrid cache for combining memory and distributed caching under a common API. Additionally, there are significant enhancements in handling spans and new functionalities like ordered GUIDs. The video provides detailed examples and real-world applications of these features.

  8. 8
    Article
    Avatar of elmahelmah.io·2y

    Exploring C# Records and Their Use Cases

    C# records, introduced in C# 9.0, provide immutable data types and value-based equality, offering a concise syntax compared to traditional classes. Records are especially useful for Data Transfer Objects (DTOs), immutable types, snapshots, and data versioning, enhancing testing and debugging with automatic `ToString()` methods and value-based equality.

  9. 9
    Article
    Avatar of godotGodot·2y

    Dev snapshot: Godot 4.4 dev 4

    The Godot 4.4 dev 4 brings numerous improvements, including bug fixes, interactive in-game editing, and optimized rendering techniques like ubershaders. Users can now pause and debug the running game directly from the editor, while the addition of object snapping enhances the 3D editing experience. Significant advancements include dedicated transfer queues and the Shadow Caster Mask property for better control over lighting effects. Users are encouraged to test the release thoroughly and report any bugs or issues to help ensure stability in future updates.

  10. 10
    Article
    Avatar of codemazeCode Maze·2y

    How to Use Pointers in C#

    Pointers in C# allow direct memory access by holding the memory address of another variable, bypassing .NET's garbage collection. This guide covers their syntax and usage in unsafe code blocks, demonstrates creating pointers to variables, and using them as method arguments. Key considerations include using the fixed statement to pin objects in memory and prevent garbage collector interference, and understanding the risks and benefits of integrating pointers in .NET projects.

  11. 11
    Article
    Avatar of hnHacker News·1y

    How Much Memory Do You Need in 2024 to Run 1 Million Concurrent Tasks?

    A benchmark comparing memory consumption for running 1 million concurrent tasks using different programming languages and async runtimes reveals surprising results. Rust and C# (with NativeAOT) are highly efficient, with C# demonstrating remarkable improvement. Surprisingly, Go and Java (GraalVM native image) perform less efficiently than expected. The study highlights the varying efficiency of async runtimes in handling a high number of tasks.

  12. 12
    Video
    Avatar of communityCommunity Picks·2y

    Stop Hardcoding Service URLs! Service Discovery in .NET Made Easy

    Learn how to implement service discovery in .NET applications to avoid hardcoding service URLs. This guide demonstrates setting up service discovery using Microsoft.Extensions.ServiceDiscovery and YARP for reverse proxying, and even incorporating it into the deployment process with Azure. Enhance your microservices' communication flexibility and ensure seamless scaling and updating by using logical names instead of static URLs.

  13. 13
    Video
    Avatar of nickchapsasNick Chapsas·2y

    The Best Way to Work with Units in .NET

    Nick demonstrates how the Units.Net library can simplify working with units of measurement in .NET applications. He outlines how the library allows easy conversions between various units such as Celsius, Fahrenheit, and Kelvin without complex code. The library also supports serialization and different cultures, making it extremely versatile for enterprise and domain-specific development.

  14. 14
    Video
    Avatar of dotnet.NET Blog·2y

    .NET Aspire for Beginners Full Series

    Jeff Fritz introduces .NET Aspire, a series designed to help developers learn about .NET Aspire, including installation, development, and deployment of applications. The series covers features such as observability, resiliency, scalability, and manageability, which are essential for building robust applications. It also addresses the integration of various tools and services like Docker and Redis, and demonstrates how to set up a development environment, convert existing .NET applications, and use .NET Aspire for both simple and complex projects.

  15. 15
    Article
    Avatar of aspnetASP.NET Blog·2y

    Get Ready for .NET Conf 2024!

    Get ready for .NET Conf 2024, a free three-day virtual conference from November 12-14, showcasing the latest in .NET. Highlights include the release of .NET 9, specialized sessions from global experts, continuous broadcasts, and exclusive digital swag. Don't miss live presentations by the .NET team and the chance to win valuable prizes.

  16. 16
    Video
    Avatar of nickchapsasNick Chapsas·1y

    The Fix For Your Database Performance Issues in .NET

    Nick demonstrates a method to enhance database performance in .NET applications using the Delta package. The solution involves adding a new 'Row Vision' column to the database, enabling efficient caching via ETags and the 304 mechanism, significantly reducing slow query times. The Delta package seamlessly integrates with existing APIs and supports heavy read scenarios, offering customization through open-source features.

  17. 17
    Article
    Avatar of elmahelmah.io·1y

    C# 13 Features: What's New and How to Use It

    C# 13, introduced with .NET 9, brings numerous enhancements to improve developer productivity and code quality. Key features include enhanced params scope, new lock type and semantics, a new escape sequence for the ESCAPE character, implicit index access, method group natural type optimization, and more extensive partial members such as properties and indexers. These updates aim to streamline coding practices, improve performance, and enhance readability.

  18. 18
    Video
    Avatar of nickchapsasNick Chapsas·2y

    The Right Way To Return API Errors in .NET

    Nick demonstrates the standardized way of returning API errors in .NET using RFC 9457. He explains how to implement this for validation errors and shows a real-world weather API example. The post discusses setting up a global exception handler and customizing error responses with detailed information like request and trace IDs. Nick also highlights a new set of design pattern courses for .NET.

  19. 19
    Article
    Avatar of collectionsCollections·2y

    Enhancements and New Features in C# 13

    C# 13 introduces several enhancements to make coding more efficient and organized. Key features include the use of 'params' with various collection types, support for partial properties, a new efficient synchronization method, and access to backing fields of auto-properties with the 'field' keyword. Additionally, 'ref' structs can now implement interfaces and be used with generics, improving performance in specific scenarios.

  20. 20
    Article
    Avatar of codemazeCode Maze·2y

    Early Binding and Late Binding in C#

    Method binding in C# can occur at compile-time (early binding) or runtime (late binding). Early binding optimizes performance and ensures type safety by resolving method calls during compilation. Late binding offers flexibility by determining methods at runtime, making it suitable for scenarios requiring adaptability despite a performance trade-off. Knowing when to use each method is crucial depending on whether the application needs high performance or dynamic type handling.

  21. 21
    Article
    Avatar of aspnetASP.NET Blog·2y

    Calling methods is easier and faster with C# 13 params collections

    C# 13 introduces a feature that allows `params` to be any of the collections supported by collection expressions, rather than just arrays. This enhancement builds on collection expressions introduced in C# 12, enabling simpler and more efficient method calls. This change optimizes performance by allowing the compiler to use stack space and special high-performance types for collection interfaces. Method overloading with `params` collections is also enhanced, providing more flexibility and better performance in applications.

  22. 22
    Article
    Avatar of codemazeCode Maze·2y

    Content Negotiation in an ASP.NET Core Minimal API Using Carter

    Learn how to implement content negotiation in ASP.NET Core Minimal APIs using the Carter library. The post discusses what content negotiation is, the limitations of Minimal APIs, and how to use Carter to support multiple content types effortlessly. Detailed steps to set up Carter and a custom XML negotiator are included, along with a comparison of using Carter versus regular ASP.NET Core Web APIs.

  23. 23
    Article
    Avatar of mwaseemzakirWaseem .NET Newsletter·2y

    Setting Up OpenAI Chat in a .NET API

    Learn how to integrate OpenAI's Chat API into your .NET application in three simple steps: obtaining your API key, installing the required NuGet package, and configuring your code. The post covers basic setup, methods and properties of the `ChatClient`, and best practices for robust implementation including handling models, securing API keys, and error management.

  24. 24
    Video
    Avatar of nickchapsasNick Chapsas·1y

    When You Shouldn't Use Await Async in .NET

    The post discusses scenarios where synchronous methods can outperform asynchronous ones in .NET, particularly with large datasets and very long strings in Entity Framework Core. A demonstration using a Docker-hosted SQL Server shows the sync version running faster and using less memory than the async version. A profiling tool, Ultra, is used to analyze and visualize the performance. Although a specific bug impacts async performance in some cases, async methods generally scale better and should typically be preferred for their non-blocking nature.

  25. 25
    Video
    Avatar of wearedotnetWe Are .NET·1y

    Getting Started with Docker for .NET Web Apps

    Learn how to integrate Docker with .NET web applications in Visual Studio. This guide demonstrates creating a Blazor server web app and adding Docker support via the IDE and the command line interface. Understand key Docker concepts like images, containers, and builds. Debugging and running your application within a Docker container on your local machine is also covered.