Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1272
This pull request updates the sample projects to modern .NET standards and refactors the code for improved clarity, null-safety, and maintainability. The most significant changes include migrating all sample projects to .NET 10, enabling nullable reference types and implicit usings, updating package references, and refactoring code to use newer APIs and patterns. Additionally, there are notable simplifications and improvements in the sample logic, especially around object/heap enumeration and argument handling.
Project and SDK Modernization:
ClrStack,DumpDict,DumpHeap,DbgEngExtension,DbgEngStandalone) are updated to targetnet10.0, with<ImplicitUsings>enable</ImplicitUsings>and<Nullable>enable</Nullable>for improved code safety and conciseness. [1] [2] [3]Microsoft.Diagnostics.Runtimeare replaced with project references to the local source, ensuring consistent builds and easier local development.Code Quality and Null-Safety Improvements:
ClrStack.cs,DumpDict.cs, andDumpHeap.csis refactored to use nullable reference types, explicit null checks, and modern C# idioms. This includes usingstring?,is null, and null-forgiving operators, as well as removing unnecessary methods and comments. [1] [2] [3] [4] [5] [6] [7]Sample Logic and API Updates:
DumpDict, the logic is updated to correctly parse arguments, use the correct field name (_entries), and handle object validation and type checks more robustly. The sample now returns exit codes instead of callingEnvironment.Exit.DumpHeap, the object enumeration and statistics collection now handle possible nullTypeproperties, preventing potential runtime exceptions.ClrStack, argument parsing and usage reporting are simplified, and exception handling is improved by using more specific exception types. [1] [2] [3] [4]DbgEngExtension Refactoring:
MAddress.cslogic for enumerating CLR memory addresses is refactored to use the newEnumerateClrNativeHeapsAPI, removing manual traversal of app domain heaps and stub heaps, and eliminating direct dependencies onDacInterface. This results in cleaner, more maintainable code. [1] [2] [3]These changes collectively modernize the samples, improve code safety, and leverage the latest APIs for better maintainability and developer experience.