Best of .NETAugust 2024

  1. 1
    Article
    Avatar of infoworldInfoWorld·2y

    Best practices for handling exceptions in C#

    Effective exception handling is crucial for building robust applications. Key practices include deriving custom exceptions from the Exception class, handling exceptions at the highest level in the call hierarchy, using specific exceptions for clarity, employing try/catch/finally blocks for resource cleanup, and avoiding the re-throwing of exceptions to maintain stack trace integrity. Always log exceptions properly and use validation logic to minimize the need for exceptions.

  2. 2
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Be Careful with Primary Constructors in C#

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

    Improving Code Quality in C# With Static Code Analysis

    Static code analysis is a vital tool for improving code quality in C# projects. It helps detect issues related to security, performance, and coding style without running the code. The post covers how to set up static code analysis using built-in Roslyn analyzers in .NET, configure properties in `Directory.Build.props`, and leverage additional tools like `SonarAnalyzer.CSharp`. The process involves treating warnings as errors and customizing rules via `.editorconfig` to create secure, maintainable, and high-quality code.

  4. 4
    Article
    Avatar of codemazeCode Maze·2y

    Advanced Debugging in C#

    This post delves into advanced debugging techniques in C# using Visual Studio 2022. It covers conditional breakpoints, tracepoints, hit count, and filter conditions. The post also explains how to change breakpoint locations, edit code during a debugging session, use the execution pointer, set function and dependent breakpoints, track variables with object IDs, and utilize string visualizers for viewing formatted strings.

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

    Understanding .NET stack traces - A guide for developers

    Learn the essentials of reading and understanding .NET stack traces for effective debugging. Discover the structure of stack traces, including inner exceptions and AggregateException, and understand the significance of source information. This guide also covers advanced stack trace scenarios like asynchronous boundaries and combined formats. Enhance your debugging skills with practical examples and tips.

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

    5 EF Core Features You Need To Know

    Discover five crucial EF Core features that can significantly improve your development process: Query Splitting to avoid performance issues with large datasets, Bulk Updates and Deletes for efficient data manipulation, Raw SQL Queries to work with unmapped types, Query Filters for reusable filtering logic, and Eager Loading to prefetch related data in a single query. These tools are designed to streamline your database management and boost performance.

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

    Introduction to Event Sourcing for .NET Developers

    Event sourcing is an architectural pattern where changes are immutably stored as events in an append-only log. This approach offers benefits like a full audit trail, improved debugging, and enhanced business insights. It requires a shift from traditional data storage methods and involves recording every change rather than the current state. Understanding key concepts such as events, state, and event stores is crucial. Although it introduces complexities and challenges, implementing event sourcing can provide significant flexibility and value in certain applications.

  8. 8
    Article
    Avatar of codemazeCode Maze·2y

    Introduction to the Wolverine Library in .NET

    The Wolverine library simplifies handling commands and asynchronous messaging in .NET applications. It allows for simple, clean code and easy integration of custom functionalities. This guide covers the installation and basic usage of Wolverine, including setting up messaging handlers and configuring queues for message transmission. It also demonstrates building an API with endpoints to handle book orders and reviews.

  9. 9
    Video
    Avatar of youtubeYouTube·2y

    C# (.NET) vs. Go (Golang): Performance Benchmark in Kubernetes

    A performance benchmark comparison between C# (.NET 8) and Golang in a Kubernetes environment, testing CPU usage, memory usage, request handling, and end-user latency. The tests include a minimal API test and a typical use case with file upload to S3 and metadata storage in a Postgres database. Golang generally performs better, with lower CPU and memory usage, while C# shows higher latency. The post includes detailed metrics and setups for monitoring using Prometheus, Grafana, and cAdvisor.

  10. 10
    Article
    Avatar of codemazeCode Maze·2y

    Differences Between Onion Architecture and Clean Architecture

    Onion and clean architectures are both used to create maintainable, scalable, and testable applications by structuring code into layers. Onion architecture is centered around a domain layer with a concentric layer approach focusing on dependency management. Clean architecture, while sharing these principles, organizes code around distinct use cases and emphasizes independence from external systems. The choice between them depends on the priority given to flexibility, business logic complexity, and team familiarity with strict guidelines.

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

    Announcing .NET Community Toolkit 8.3

    The .NET Community Toolkit 8.3 introduces support for .NET 8 and NativeAOT, along with multiple performance improvements and bug fixes. Key changes include annotation updates for trimming and AOT compatibility, a new target framework for MVVM Toolkit, and a pay-for-play model to remove overhead when unused. The release also addresses various issues reported by the community, enhancing overall toolkit functionality.

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

    Introduction to Guard Clauses in .NET

    Guard clauses in .NET are used to ensure code robustness, maintainability, and readability by handling invalid input at the beginning of methods and reducing nested code. Using libraries like Ardalis.GuardClauses can simplify their implementation and allow for custom guard definitions, leading to cleaner and more maintainable code.

  13. 13
    Article
    Avatar of codemazeCode Maze·2y

    Differences Between Record Struct and Record Class in C#

    The post highlights the differences between record structs and record classes in C#. Record classes are reference types allocated on the heap, while record structs are value types allocated on the stack. Record classes support inheritance and are immutable by default when using a primary constructor or init-only setters. In contrast, record structs do not support inheritance and require the 'readonly' keyword for immutability. These types are primarily used for lightweight, immutable data structures.

  14. 14
    Video
    Avatar of communityCommunity Picks·2y

    Best Practices for Secure Password Hashing in .NET (Stop Storing Passwords in Plain Text!)

    Milan demonstrates secure password hashing in .NET, explaining the importance of hashing and salting to improve system security. He outlines the step-by-step implementation for a secure password hasher service. Key points include using SHA-512 for hashing, generating random salt values, and how to verify hashed passwords during user login, ensuring the protection against brute force and timing attacks.

  15. 15
    Article
    Avatar of codemazeCode Maze·2y

    Run a Large Language Model(LLM) Like ChatGPT Locally With C#

    Experience the power of running a Large Language Model (LLM) like ChatGPT locally on your computer using LLamaSharp. This cross-platform library leverages C++ library llama.cpp to integrate LLMs into C# applications. Key steps include installing the LLamaSharp package, choosing an appropriate model, and configuring the model parameters. Practical use cases and code snippets are provided to demonstrate setting up a chat session and interacting with the deployed model effectively.

  16. 16
    Article
    Avatar of infoqInfoQ·2y

    Microsoft Releases Prompty: New VS Code Extension for Integrating LLMs into .NET Development

    Microsoft has launched Prompty, a free Visual Studio Code extension that integrates Large Language Models (LLMs) like GPT-4o into .NET development. Prompty simplifies the process of adding AI capabilities, such as generating content or creating chatbots, directly within the development environment. It includes features like easy installation, API key configuration, prompts integration, and syntax highlighting. Despite positive reception, some users are concerned about its availability for Visual Studio Professional. A real-world example shows Prompty enhancing a .NET WebAPI project with detailed weather forecast descriptions, leveraging Semantic Kernel for automation.

  17. 17
    Article
    Avatar of bartwullemsThe Art of Simplicity·2y

    C# 12- Type Aliasing

    In .NET applications, using a GlobalUsings.cs file to centralize all `using` directives has become a common pattern. This file can also include type aliases. Global usings, introduced in C# 10, allow declaring a namespace once and making it available across the application. Type aliasing in C# allows mapping to other types, including tuples and non-open generics. However, type aliasing does not work with nullable reference types.

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

    Building an ASP.NET Core Web API with Gridify

    Gridify is a powerful and lightweight library designed to simplify data filtering, sorting, and pagination in ASP.NET Core Web APIs. It integrates seamlessly into existing projects, supporting complex data structures and custom mappings. This guide demonstrates how to set up an ASP.NET Core Web API project with Gridify, covering essential features like dynamic filtering, sorting, and pagination. Gridify helps reduce repetitive code, making APIs more maintainable and efficient.

  19. 19
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Stop Using IEnumerable The Wrong Way in .NET! | Code Cop #019

    In this post, Nick addresses the common misconceptions about using IEnumerable in .NET, particularly the misuse of the ConvertAll method. He highlights the flaws in benchmarking methods and emphasizes the importance of understanding deferred execution in IEnumerable. Nick also demonstrates more accurate benchmarking practices and reinforces the nuanced performance differences between ConvertAll and the Select method from LINQ.

  20. 20
    Video
    Avatar of nickchapsasNick Chapsas·2y

    The New Option and Result Types of C#

  21. 21
    Article
    Avatar of devblogsDevBlogs·2y

    Adding .NET Aspire to your existing .NET apps

    Adding .NET Aspire to existing .NET applications simplifies development by enabling features like health checks, logging, and resiliency without altering your CI/CD pipeline. You can integrate Service Defaults to activate recommended settings for ASP.NET Core distributed apps quickly. Additionally, the AppHost provides a dashboard to manage multiple projects, aggregate logs, and monitor health checks efficiently, enhancing the developer experience.

  22. 22
    Video
    Avatar of nickchapsasNick Chapsas·2y

    The Smart Way to Add Database Auditing in .NET

  23. 23
    Article
    Avatar of devleaderDev Leader·2y

    Zero to Hero: Reflection in .NET

    Explore the comprehensive course on mastering reflection in .NET, guiding you from the basics to advanced concepts and practical applications.

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

    .NET and .NET Framework August 2024 updates

    The August 2024 updates for both .NET and .NET Framework have been combined into a single post for convenience. Two security vulnerabilities have been addressed this month, though there are no new security updates for .NET Framework. Key updates include releases for .NET 6.0.33 and .NET 8.0.8. For more details, refer to the release notes linked in the post.

  25. 25
    Article
    Avatar of codemazeCode Maze·2y

    Dynamically Change the ServiceLifetime of a Registered Service in .NET

    Managing dependencies effectively is crucial in modern application development. This guide covers how to change the ServiceLifetime of registered services in .NET, which is especially useful for optimizing performance in various environments like development, staging, or production. The post provides reusable extension methods to replace service registrations with different lifetimes, such as Singleton, Scoped, or Transient. Practical examples demonstrate how to implement these methods, ensuring flexibility and control over application dependencies.