Skip to content

Fix Name property truncation for generic methods with type parameters#1362

Open
leculver wants to merge 4 commits intomicrosoft:mainfrom
leculver:issue_935
Open

Fix Name property truncation for generic methods with type parameters#1362
leculver wants to merge 4 commits intomicrosoft:mainfrom
leculver:issue_935

Conversation

@leculver
Copy link
Contributor

@leculver leculver commented Feb 12, 2026

Fixes some truncation issues outlined in #935. Fixes #842.

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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Name parsing to skip bracketed generic argument sections when searching for the type/method separator dot.
  • Add regression tests covering ClrMethod.Name parsing 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.

@leculver leculver marked this pull request as draft February 12, 2026 19:44
@leculver
Copy link
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.
@leculver leculver marked this pull request as ready for review February 13, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClrMethod.Name returns incorrect result when signature has function pointers

1 participant

Comments