Fix Name property truncation for generic methods with type parameters#1362
Open
leculver wants to merge 4 commits intomicrosoft:mainfrom
Open
Fix Name property truncation for generic methods with type parameters#1362leculver wants to merge 4 commits intomicrosoft:mainfrom
leculver wants to merge 4 commits intomicrosoft:mainfrom
Conversation
The Name property was using LastIndexOf('.') which found dots inside
generic type parameter brackets (e.g., System.Private.CoreLib), causing
names like 'CoreLib]]' instead of the correct method name.
Now skips over bracket-enclosed generic parameters when searching for
the type-method separator dot.
Fixes part of microsoft#935
…icrosoft#935) Three new tests validate the bracket-aware dot-search logic in the Name property against every method in the dump (BCL + test targets): - MethodName_InvariantsHoldForAllMethods: scans all methods and checks balanced brackets, no namespace dots in method identifiers, and that Name + '(' appears in the Signature. Covers thousands of real CLR method signatures. - MethodName_GenericBracketSignatures_NotTruncated: focuses on methods whose signatures contain [[...]] generic parameters before '(' and verifies the Name is not truncated into the bracket expression (the original issue microsoft#935 bug where 'CoreLib]]' was returned). - MethodName_Constructors_CorrectlyIdentified: verifies .ctor/.cctor double-dot prefix handling and IsConstructor/IsClassConstructor properties across all constructors in the dump.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ClrMethod.Name extraction for generic method signatures where type-argument brackets contain dots (e.g., System.Private.CoreLib), addressing truncation reported in #935.
Changes:
- Update
ClrMethod.Nameparsing to skip bracketed generic argument sections when searching for the type/method separator dot. - Add regression tests covering
ClrMethod.Nameparsing behavior across generic bracket signatures and constructors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Microsoft.Diagnostics.Runtime/ClrMethod.cs |
Adjusts Name parsing to avoid selecting dots inside [[...]] generic argument clauses. |
src/Microsoft.Diagnostics.Runtime.Tests/src/MethodTests.cs |
Adds multiple regression tests intended to detect Name truncation and related invariants. |
Contributor
Author
|
Missed another issue related, need to make updates. |
Integrate issue microsoft#842 fix (function pointer nested parentheses) into the issue microsoft#935 branch (generic bracket dot-search). The Name property now: 1. Finds the outermost '(' using paren-depth matching, skipping nested parentheses from function pointer types like 'Void* (Void*, UInt32)'. (issue microsoft#842) 2. Skips over generic parameter brackets [[...]] before searching for the type-method separator dot. (issue microsoft#935) Also adds a parentheses-in-Name invariant check to the comprehensive regression test, ensuring issue microsoft#842 regressions are caught.
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 some truncation issues outlined in #935. Fixes #842.