Skip to content

Improve debugging experience of ClaimsPrincipal #86421

Closed
@JamesNK

Description

@JamesNK

In ASP.NET Core we're trying to improve the debug experience of HttpContext. One of the properties on HttpContext is the current user, represented by ClaimsPrincipal. Today it has a relatively standard debug experience. You can see it below in screenshots. A couple of debugger display attributes should make it easier to see important information at a glance.

ClaimsIdentity:

image

Debugger could display "Name: {Name}, IsAuthenticated: {IsAuthenticated}, Claims count: {Claims.Count}"

ClaimsPrincipal:

image

The usual case for a ClaimsPrincipal is one primary identity. In that case, it could just display information about that identity: "Identity name: {Identity.Name}, IsAuthenticated: {Identity.IsAuthenticated}, Claims count: {Identity.Claims.Count}"

If ClaimsPrincipal has multiple identities, then it could display more general information: "Identity count: {Identities.Count}, Claims count: {Claims.Count}".

Also, the Claims property should show the count. How do you customize the debug display of a yield enumerable method? Can you add a debugger display attribute to a property?

Claim:

image

Claim has a ToString() already and looks good in the debugger.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions