Skip to content
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

Improve debug views of dictionaries #52867

Merged
merged 6 commits into from
Dec 19, 2023

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Dec 18, 2023

Fixes #51827

Update custom dictionaries in ASP.NET Core to display the key in the name column. There are a lot of dictionaries and I haven't tested all of them, but reusing debugger proxies on most dictionary types means they should just work.

Background: .NET debugging has supported customizing the name for years, but for some reason dictionaries have always displayed a meaningless index in the name column instead of the item key. See dotnet/runtime#88736


Items before:
image

Items after:
image


Cookies before:
image

Cookies after:
image


Request headers before:
image

Request headers after:
image


Route values before:
image

Route values after:
image


Features before:
image

Features after:
image

@JamesNK JamesNK added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Dec 18, 2023
@Meligy
Copy link

Meligy commented Dec 18, 2023

I have mixed feelings about this. Not sure I want to lose sight of index. Although I welcome an easier to read key.

Is 3 columns easily possible? Or some format that preserves the index?

@JamesNK
Copy link
Member Author

JamesNK commented Dec 18, 2023

Three columns isn't possible. What do you want the existing number in the name column for? It is meaningless. The new value is actually the index.

For example:

var headers = new Dictionary<string, string> { ["content-type"] = "application/json" };
var v1 = headers["content-type"]; // works
var v2 = headers[0]; // trying to use the number causes a compile error that a string is expected

And displaying the number becomes confusing in the cases when the dictionary key is an integer:

var products = new Dictionary<int, string> { [1] = "Apple", [0] = "Orange" };

image

@halter73
Copy link
Member

One more thing. In the screenshot, one of the headers shows up as ["Accept-Encoding"] "gzip, deflate, br". It should probably be ["Accept-Encoding"] "gzip", "deflate", "br". This would make it easier to tell if the request was

Accept-Encoding: gzip
Accept-Encoding: deflate
Accept-Encoding: br

vs

Accept-Encoding: gzip, deflate, br

Of course, the server should handle it the same way, but I could see it mattering for query strings or something. Since quotes inside the StringValue are already getting escaped with \", I think it would only make it more clear to quote each value independently when there are multiple.

@JamesNK
Copy link
Member Author

JamesNK commented Dec 18, 2023

I took a look at the value and at least in this case the StringValues is one string:
image

I presume Chrome is sending the header as one comma delimited value instead of separate values.

@JamesNK JamesNK merged commit 154177c into main Dec 19, 2023
26 checks passed
@JamesNK JamesNK deleted the jamesnk/dictionary-namevalue-debugging branch December 19, 2023 08:56
@ghost ghost added this to the 9.0-preview1 milestone Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debugging: Update dictionary debuggers in aspnetcore to follow the new standard
4 participants