-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Dashboard support showing generic class names #9924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ReubenBond
merged 4 commits into
dotnet:main
from
hendrikdevloed:feature/dashboard-generic-class-names
Feb 17, 2026
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
87eb5df
Properly render and shorten generic class names
hendrikdevloed-dekimo b42b858
Preserve method names
hendrikdevloed-dekimo ce22268
Update src/Dashboard/Orleans.Dashboard.App/src/lib/typeName.ts
hendrikdevloed d8abdfc
Address dashboard generic-name PR feedback
ReubenBond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
102 changes: 102 additions & 0 deletions
102
src/Dashboard/Orleans.Dashboard.App/src/lib/typeName.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| export function getName(value: string): string { | ||
| // Parse a type name and shorten fully-qualified names to their last segment. | ||
| // Handles generic type arguments (angle brackets or square brackets) and | ||
| // shortens their content recursively. Examples: | ||
| // "A.B.C<T.U.V>" -> "C<V>" | ||
| // "G<X.Y<Z.W>>" -> "G<Y<W>>" | ||
| function trimIdentifier(id: string): string { | ||
| if (!id) return id; | ||
| id = id.trim(); | ||
| // Remove assembly details if present: "Type, Assembly" | ||
| const comma = id.indexOf(','); | ||
| if (comma !== -1) id = id.substring(0, comma).trim(); | ||
| const parts = id.split('.'); | ||
| return parts[parts.length - 1]; | ||
|
hendrikdevloed marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
|
ReubenBond marked this conversation as resolved.
Outdated
|
||
| function parseType(str: string): string { | ||
| if (!str) return str; | ||
| let s = str.trim(); | ||
|
|
||
| // Find first generic opener: '<' or '[' | ||
| const lt = s.indexOf('<'); | ||
| const lb = s.indexOf('['); | ||
| let opener = ''; | ||
| let openerPos = -1; | ||
| let closer = ''; | ||
| if (lt !== -1 && (lb === -1 || lt < lb)) { | ||
| opener = '<'; closer = '>'; openerPos = lt; | ||
| } else if (lb !== -1) { | ||
| opener = '['; closer = ']'; openerPos = lb; | ||
| } | ||
|
|
||
| if (openerPos === -1) { | ||
| return trimIdentifier(s); | ||
| } | ||
|
|
||
| const main = s.substring(0, openerPos); | ||
|
|
||
| // Find matching closer for the opener, honoring nested pairs | ||
| let depth = 0; | ||
| let end = -1; | ||
| for (let i = openerPos; i < s.length; i++) { | ||
| const ch = s[i]; | ||
| if (ch === opener) depth++; else if (ch === closer) { | ||
| depth--; if (depth === 0) { end = i; break; } | ||
| } | ||
| } | ||
|
|
||
| if (end === -1) { | ||
| return trimIdentifier(s); | ||
| } | ||
|
|
||
| const inner = s.substring(openerPos + 1, end); | ||
| const remainder = s.substring(end + 1); | ||
|
|
||
| // Split inner by top-level commas only | ||
| const args: string[] = []; | ||
| let argStart = 0; | ||
| depth = 0; | ||
| for (let i = 0; i < inner.length; i++) { | ||
| const ch = inner[i]; | ||
| if (ch === '<' || ch === '[') depth++; else if (ch === '>' || ch === ']') depth--; | ||
| else if (ch === ',' && depth === 0) { | ||
| args.push(inner.substring(argStart, i)); | ||
| argStart = i + 1; | ||
|
ReubenBond marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| args.push(inner.substring(argStart)); | ||
|
|
||
| const parsed = args.map(a => parseType(a)); | ||
|
|
||
| // If there is a remainder after the generic (e.g. ".Method"), | ||
| // preserve it while shortening each dotted segment inside it. | ||
| function parseSuffix(rem: string): string { | ||
| if (!rem) return ''; | ||
| let i = 0; | ||
| // accept leading dots/spaces | ||
| while (i < rem.length && (rem[i] === '.' || rem[i] === ' ')) i++; | ||
| if (i === 0) return rem; // unexpected format, return raw | ||
|
|
||
| const segments: string[] = []; | ||
| let segStart = i; | ||
| let depth = 0; | ||
| for (let j = i; j < rem.length; j++) { | ||
| const ch = rem[j]; | ||
| if (ch === '<' || ch === '[') depth++; else if (ch === '>' || ch === ']') depth--; | ||
| else if (ch === '.' && depth === 0) { | ||
| segments.push(rem.substring(segStart, j)); | ||
| segStart = j + 1; | ||
| } | ||
| } | ||
| if (segStart <= rem.length) segments.push(rem.substring(segStart)); | ||
|
|
||
| const parsedSegs = segments.map(seg => parseType(seg)); | ||
| return '.' + parsedSegs.join('.'); | ||
| } | ||
|
|
||
| return `${trimIdentifier(main)}<${parsed.join(', ')}>${parseSuffix(remainder)}`; | ||
| } | ||
|
|
||
| return parseType(value); | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.