Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: dotnet


How to Enjoyably Develop .NET with AnduinOS

This article aims to provide .NET developers with a guide for setting up a development environment in VSCode on AnduinOS or any Linux system that closely mimics the Visual Studio experience. It begins by noting that, due to the lack of a free Visual Studio and the absence of a Rider Community Edition, VSCode emerges as an ideal alternative. The core content recommends the C# extension and its key settings, such as enabling OmniSharp decompilation support, EditorConfig, and the Roslyn analyzer, to enhance basic functionality. For advanced needs, it introduces the C# Dev Kit and its intelligent completion components, while cautioning about its commercial licensing restrictions and account login requirements. Additionally, it recommends Roslynator as a lightweight alternative for code analysis and refactoring, along with practical plugins for automatically generating XML documentation comments and completing namespaces. The article also briefly discusses the pros and cons of GitHub Copilot. The author emphasizes that these configurations can significantly improve development efficiency and invites readers to share further optimization suggestions, aiming to help developers achieve a smoother C# development experience on Linux platforms.

Views 206
.NET AnduinOS C# VSCode development-environment dotnet github-copilot vscode-plugins

A comic strip explaining the principles of .NET garbage collection (GC)

Set against the backdrop of the 2023 Lunar New Year's Eve, this article explores the prevalent "assembly-line" development predicament faced by .NET developers in China. It points out that many developers focus solely on business-level CRUD operations while neglecting underlying technical principles, which hinders their long-term career growth. The author advocates breaking through this bottleneck via performance optimization, emphasizing that reducing Garbage Collection (GC) pressure is the core entry point for .NET performance tuning. The article translates and introduces a classic .NET GC principle comic created by Redgate, aiming to provide foundational technical education for developers. Additionally, it offers an in-depth analysis of the technical challenges involved in Large Object Heap (LOH) compaction. It mentions a temporary workaround involving setting `GCSettings.LargeObjectHeapCompactionMode` to `CompactOnce`, but notes that this method has time-sensitivity limitations and requires manual intervention, effectively reverting to the complexity of manual memory management. The article advises readers to deepen their understanding of .NET's memory management mechanisms by adopting a multi-language programming perspective.

Views 103
.NET comic translation dotnet garbage collection large object heap performance optimization

What is asynchrony? Is asynchrony the same as multithreading? Is asynchrony just `async` and `await`?

This article provides an in-depth analysis of the fundamental differences between `await` and `Task` in C# asynchronous programming. Through code-based evidence, it demonstrates that it is `Task.Run`, not the `await` keyword, that initiates a new thread. The core function of `await` lies in non-blockingly waiting for asynchronous operations to complete, creating continuations, and unwrapping `Task<T>` to retrieve return values. The article corrects the common misconception that one must use `await` to invoke asynchronous methods, clarifying that calling an asynchronous method starts its execution immediately. Developers can execute other logic before `await`, thereby enabling the parallel execution of multiple asynchronous tasks to optimize performance. Additionally, the article introduces methods for returning already-completed tasks using `Task.FromResult` and `Task.CompletedTask` without using the `async` modifier, and recommends using `Task.WhenAll` to wait simultaneously for multiple independent tasks to complete. Finally, it emphasizes the importance of understanding underlying principles for the safe and efficient use of asynchronous programming.

Views 59
Async Await C# Multithreading Task Task Parallelism dotnet

Thoroughly understand what ASCII, Unicode, UTF-8, and UTF-32 are, as well as their differences and relationships

This article provides an in-depth analysis of the core logic and distinctions among encoding systems such as ASCII, Unicode, and UTF-8. ASCII addresses the digital storage of English through a mapping of 128 characters, while Unicode introduces the concepts of graphemes and code points to support global languages, achieving unified identification for over 100,000 characters. In terms of encoding strategies, UTF-32 facilitates indexing but suffers from significant space waste, whereas UTF-8 balances compatibility and efficiency through variable-length encoding of 1 to 4 bytes, making it the mainstream choice. The article emphasizes that within the Unicode system, a grapheme is not equivalent to a code point, nor is it equivalent to a byte. This complexity results in different programming languages defining string length differently; for instance, Python, C#, and Go yield different results when handling multi-byte characters such as Emojis. Developers need to distinguish between functions for imperceptible Unicode, perceptible Unicode, and perceptible graphemes to avoid garbled text and logical errors. Understanding the difference between character codes and character encodings, and mastering the underlying encoding rules of each language, is a critical foundation for handling multilingual text and ensuring accurate data storage and parsing.

Views 74
ASCII Character Encoding Go Programming Language UTF 8 Unicode dotnet