Best of .NETSeptember 2024

  1. 1
    Article
    Avatar of communityCommunity Picks·2y

    Faster Dictionary in C#

    The .NET Base Class Library's Dictionary<TKey, TValue> offers constant time access to values, but duplicated lookups can reduce efficiency. Utilizing the TryAdd method in .NET Core 2.0 can prevent duplicate lookups and boost performance. Additionally, .NET 6 introduced methods in System.Runtime.InteropServices.CollectionsMarshal to address duplicate lookup scenarios using managed pointers. These methods, alongside managed pointers and the ref keyword, can significantly speed up dictionary operations, particularly with structs and large structures. However, it's crucial to handle managed pointers cautiously to avoid potential issues with dictionary reorganization.

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

    EP 66 : Clean Code Tips for .NET Developers - Part I

    This post provides clean code tips for .NET developers, focusing on giving meaningful names, avoiding null returns, keeping class and method sizes small, not reinventing the wheel, and using appropriate tools or IDEs. It also offers practical examples and suggestions for better coding practices in .NET projects.

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

    Performance Improvements in .NET 9

    Exciting performance improvements are packed into .NET 9, making it the best and fastest release so far. More than 7,500 pull requests, with a significant focus on performance, contribute to this release. Key highlights include dynamic profile-guided optimization (PGO), enhanced just-in-time (JIT) compiler optimizations, refined tier 0 compilation, loop optimizations, and reductions in bounds checking overheads. These changes collectively enhance runtime efficiency, memory management, and overall application speed.

  4. 4
    Article
    Avatar of telerikTelerik·2y

    Tips for Improving API Performance in ASP.NET Core

    Learn how to optimize APIs in ASP.NET Core to improve performance and scalability with techniques including caching, asynchronous communication, pagination, and efficient code practices. These methods can reduce latency, enhance user experience, and optimize server resource usage. Examples provided include moving to async methods, implementing pagination, using AsNoTracking in Entity Framework, and employing both in-memory and distributed caching.

  5. 5
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Stop Using FirstOrDefault in .NET! | Code Cop #021

    Nick explains why using the Find method over FirstOrDefault in .NET lists can be a misleading practice. He highlights performance comparisons and how optimizations in .NET 9 make FirstOrDefault faster, emphasizing the importance of understanding such nuances to avoid harming code and performance.

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

    Refit in .NET: Building Robust API Clients in C#

    Refit is a type-safe REST library for .NET that simplifies interacting with APIs by turning them into interfaces. This reduces boilerplate code, handles serialization automatically, and makes API calls more readable and maintainable. The post provides steps to set up Refit, including installing necessary packages, defining an interface for API calls, configuring dependencies, and handling query parameters, headers, and authentication. Refit also offers options for JSON serialization and more control over HTTP responses.

  7. 7
    Article
    Avatar of communityCommunity Picks·2y

    Advance Your .NET and Architecture Skills

    Discover a modern approach to handle entity identification in .NET by using strongly typed IDs, which address the issue of primitive obsession with entity identifiers.

  8. 8
    Video
    Avatar of communityCommunity Picks·2y

    Secure Your .NET Application With Keycloak: Step-by-Step Guide

    Learn how to secure your .NET application using Keycloak, an open-source identity provider compatible with OAuth2 and OpenID. This guide covers setting up a Keycloak realm and client, configuring authentication with JSON Web Tokens (JWT), and implementing an API endpoint for user claims. The tutorial also dives into using distributed tracing with OpenTelemetry to validate and debug your authentication setup.

  9. 9
    Article
    Avatar of codemazeCode Maze·2y

    How to Use the REPR Pattern in .NET

    The REPR (Request-Endpoint-Response) design pattern in .NET emphasizes API design around endpoints instead of controllers, improving organization and maintainability. Created by Steve Smith, it ensures adherence to the Single Responsibility Principle (SRP). The post explains how to implement the REPR pattern using the FastEndpoints library in a .NET project, highlighting the advantages and potential drawbacks of this approach.

  10. 10
    Article
    Avatar of codemazeCode Maze·2y

    Manage Background Tasks in .NET

    The IHostedLifecycleService interface in .NET extends the IHostedService interface to offer finer control over the lifecycle of hosted services. It introduces additional methods to manage actions before and after the service starts and stops. This allows for the execution of crucial tasks like initialization and resource disposal at precise points. Concurrent startup and shutdown of services, introduced in .NET 8, further enhance this capability, enabling more efficient and resilient applications, particularly when multiple services are involved.

  11. 11
    Article
    Avatar of communityCommunity Picks·2y

    How to Create Your First Minimal API with .NET 8

    Learn how to create your first Minimal API using .NET 8, perfect for newcomers or those looking to explore new features. This guide covers setting up your environment, creating a new project, and adding endpoints step-by-step. Minimal APIs are ideal for lightweight applications and microservices.

  12. 12
    Article
    Avatar of telerikTelerik·2y

    Best Practices in Building ASP.NET Core API Projects

    Building an effective ASP.NET Core API project involves applying SOLID principles and leveraging design patterns to structure the backend. Key decisions include choosing between API Controller classes and minimal APIs, managing Program.cs file size, organizing services to avoid bottlenecks, and implementing proper versioning. Using facades or orchestrators can help streamline client requests across multiple services, while structuring projects by features ensures maintainability. Employing the ASP.Versioning.Http NuGet package can aid in handling versioning gracefully.

  13. 13
    Article
    Avatar of codemazeCode Maze·2y

    StringValues in ASP.NET Core

    StringValues is a specialized type in ASP.NET Core designed to efficiently handle collections of strings, especially useful for scenarios involving HTTP headers, query strings, and form data. Unlike naive implementations using arrays or older solutions like NameValueCollection, StringValues minimizes memory allocations by using a single internal object to represent multiple strings. This enhances performance and scalability, making it ideal for high-traffic web applications.

  14. 14
    Video
    Avatar of nickchapsasNick Chapsas·2y

    TUnit: The Future of Testing in .NET

    TUnit is a new testing library for .NET that offers significant modernization and control for unit and integration testing. It leverages source generation for faster test execution and provides advanced features like async assertions, hooks for setup and teardown, multi-threaded test execution, and retry mechanisms for flaky tests. The library is highly configurable and supports dependency injection and compile-time checks, which enhance the robustness and flexibility of tests. The post discusses these features in detail using a simple calculator test as an example and encourages readers to try out TUnit and provide feedback.

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

    Why is F# code so robust and reliable?

    F# has proved to be a robust and reliable language for software development, as demonstrated by the success of the EasyCoin project by Access Softek. Key features contributing to this success include immutability by default, discriminated unions with exhaustive checks, the absence of nulls and exceptions in business logic, strict dependency order, warnings on unused expressions, typed primitives, explicit conversions, and a functional approach to concurrency. These features collectively reduce bugs and enhance code predictability and safety.

  16. 16
    Article
    Avatar of csharpcornerC# Corner·2y

    How C# Manages Memory Automatically

    C# handles memory management automatically through a process called garbage collection, which manages the allocation and deallocation of memory. The garbage collector uses techniques like reference counting and generation-based collection to identify and reclaim memory from objects that are no longer in use. Developers can use constructs such as the 'using' statement to ensure proper disposal of objects, which helps in managing resources efficiently and avoiding memory leaks.

  17. 17
    Video
    Avatar of youtubeYouTube·2y

    .NET and C# are in trouble. Here is what I'd do.

    The current rapid release cycle of .NET and C# is causing exhaustion among developers, who struggle to keep up with frequent changes. This post discusses issues with the release schedule, lack of built-in administrative tools, and limited long-term support, comparing the framework’s approach to others like Django and Node.js. Emphasizing that extending support periods and addressing these gaps could help in better adoption of .NET and C#.

  18. 18
    Article
    Avatar of medium_jsMedium·2y

    .NET 9: Task.WhenEach and Prioritized Channels

    Discover the new thread management features in .NET 9, including the `Task.WhenEach` API for simplified task iteration using `await foreach` loops, and prioritized unbounded channels for flexible task prioritization. These features offer efficient, responsive task processing and improved control over execution priorities in multi-threaded environments.

  19. 19
    Video
    Avatar of nickchapsasNick Chapsas·2y

    The Free Way to Create Awesome PDFs in .NET

    Learn how to generate PDFs in .NET for free without relying on paid libraries. This method uses HTML and Playwright to create flexible, componentized PDFs, suitable for most use cases. By leveraging Razor components and avoiding the need for libraries like iron PDF or quest PDF, this approach ensures cost-effectiveness and versatility, especially for generating invoices or similar documents.

  20. 20
    Article
    Avatar of communityCommunity Picks·2y

    Building Multi-Architecture Docker Images with Buildx

    Learn how to use Docker Buildx to compile multi-architecture images for .NET, Rust, and Golang, allowing your applications to run seamlessly on both x64 and ARM64 architectures. The guide covers setting up a Dockerfile, creating a Buildx builder instance, building and pushing the images, and cleaning up resources after the build.

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

    .NET 9 Release Candidate 1 is now available!

    .NET 9 Release Candidate 1 introduces enhanced WebSocket APIs, new compression options, advanced SignalR tracing, and updates to .NET MAUI for improved text alignment. .NET Conf 2024 is slated for November 12-14 to celebrate the .NET 8 release. Key updates include WebSocket keep-alive pings, new compression methods, and improvements in SignalR distributed tracing. Install the .NET 9 SDK and stay up-to-date with the new release through GitHub Discussions.

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

    .NET Aspire: A Game-Changer for Cloud-Native Development?

    Microsoft's .NET Aspire is an opinionated, cloud-ready stack designed to simplify the process of building, deploying, and managing distributed applications. It provides a streamlined setup using .NET Aspire Orchestration, making configurations and integrations more straightforward with built-in observability tools for logging, metrics, and distributed tracing. While Aspire simplifies the setup and monitoring of complex systems, it may present a learning curve for newcomers to cloud-native development. It is particularly well-suited for Azure deployments but requires careful evaluation for simpler applications or non-Azure services.

  23. 23
    Article
    Avatar of devblogsDevBlogs·2y

    Learn to Build Your First Blazor Hybrid App!

    The official Blazor Hybrid workshop teaches the basics of building a cross-platform app using Blazor Hybrid, featuring step-by-step instructions for creating the MonkeyFinder app. It covers project structure, data loading, third-party libraries, platform functionalities, theming, and combining Blazor with .NET MAUI native pages. It's suitable for both self-paced learning and teaching others, with resources including code, slides, and extensive instructions. A full 4-hour course by Gerald is also available on YouTube.

  24. 24
    Article
    Avatar of dotnet.NET Blog·2y

    GitHub Models and .NET: Building Generative AI apps for engineers

    GitHub Models is breaking down barriers to accessing AI models, offering a seamless integration with development environments like GitHub Codespaces and VS Code. The public beta lets developers test models like GPT-4o, Phi 3, Mistral Large 2, and Llama 3.1 within the GitHub UI. With built-in responsible AI practices, global availability via Azure, and robust support through the Azure AI Inference SDK, .NET developers can easily incorporate these models into their applications. Join the GitHub Models private beta and start experimenting with AI capabilities today.