-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 docs for BinaryData.ToString() #56325
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
In general I don't have a concern with clarifying docs, but it does strike me as a bit weird to call out JSON string behavior specifically. Why are JSON strings promoted to a first-class citizen within the remarks section, but JSON objects/arrays aren't mentioned, and weirdness resulting from |
Yes, this is motivated by users not understanding how to get a JSON string and being confused by the output from ToString. I'm not sure how an analyzer would work in general here as we would not be able to tell whether it is a valid ToString usage or not. The main goal is to just introduce the idea of |
Tagging subscribers to this area: @GrabYourPitchforks, @dotnet/area-system-memory Issue Details
|
@JoshLove-msft What would a "valid" @bartonjs Do you have thoughts on this? In recent reviews you've mentioned concerns about users calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved to unblock this since it's an improvement over the current situation. But per feedback in the issue conversation, I think relying solely on docs is the wrong long-term solution, and we need to think about more in-your-face mechanisms to steer users toward correct behaviors.
ToString does UTF-8 conversion, so any UTF-8 encoded bytes would be valid. It isn't necessarily invalid to call ToString on JSON, it is just probably not want the user wants in most cases, since there are special JSON deserialization methods on BinaryData. A case where it makes sense to use ToString would be when you are using some other textual represenation, e.g. plaintext, or XML, where BinaryData does not also have specialized methods for handling those formats. In those cases, ToString makes sense. I agree that it is somewhat ambiguous, and that this is something of a usability bandaid. |
Co-authored-by: Jeremy Barton <[email protected]>
Hello @adamsitnik! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied all the suggestions and pushed them directly to @JoshLove-msft branch. LGTM
Failures are unrelated (#56894), merging |
Note this won't appear on the docs site until we run the porting tool again. If the goal is to get the changes on the doc site it's probably easiest to create another PR against dotnet/dotnet-api-docs. |
No description provided.