Best of C#August 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
    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.

  3. 3
    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.

  4. 4
    Article
    Avatar of atomicobjectAtomic Spin·2y

    4 Tips for Writing More Testable Code

    Learn how to make your code more testable by choosing specific input types, avoiding object mutations, keeping complex logic out of the database, and creating new modules or services when needed. These practices not only facilitate easier testing but also improve overall code quality and maintainability.

  5. 5
    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.

  6. 6
    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.

  7. 7
    Article
    Avatar of game_developersGame Developers·2y

    The Beauty of Godot and Open Source Game Develpment

    Godot is highly recommended for beginners in game development due to its ease of use and the ability to participate in large projects. Thrive, an open-source game similar to Spore 2 and developed under the GNU GPLv3.0-or-later, is suggested as a good starting point, especially for those familiar with Unity, as it uses C#.

  8. 8
    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.

  9. 9
    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.

  10. 10
    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.

  11. 11
    Article
    Avatar of jetbrainsJetBrains·2y

    Join Us for JetBrains GameDev Days 2024

    Join JetBrains GameDev Days 2024 for a hybrid event on October 9-10. The event features experts discussing topics like CI/CD processes, Unity's DOTS, C# scripting, and game development with Godot. In-person sessions will occur on October 9, followed by an online event on October 10. Talks will cover Unreal Engine development, mobile game development, Godot with Kotlin, and more. Sessions will be streamed live on YouTube and will remain available afterward.

  12. 12
    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.

  13. 13
    Article
    Avatar of godotGodot·2y

    Release candidate: Godot 4.3 RC 3

    Godot 4.3 RC 3 has been released with several regressions fixed from previous candidates. Major highlights include numerous bug fixes and stability improvements in animations, core resource loading, editor dialogs, GDScript, GUI, input handling, multiplayer protocols, network settings, porting specifics for Windows and macOS, and rendering systems. Contributions are welcome, as Godot is an open-source project maintained by volunteers and a small team of paid contributors. Users can download and test this new release and report any issues on GitHub.

  14. 14
    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.

  15. 15
    Article
    Avatar of game_developersGame Developers·2y

    Preparing My First Unity Game

    Starting with Unity 2017.4.40f1, the author is learning the engine to develop their first game, overcoming challenges with C# integration and UI understanding. Opting for a pixel art style, they share some assets and tease a unique game concept.

  16. 16
    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.