dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.18k stars 5.85k forks source link

Clarify whitespace handling for multi-line Raw String Literals #32215

Closed techfan101 closed 1 year ago

techfan101 commented 1 year ago

In the section entitled "Raw String Literals", please consider clarifying the documentation of whitespace handling for strings that span multiple lines. In that section, the following sentence does not fully convey the behavior:

In multi-line raw string literals, any whitespace to the left of the closing quotes is removed.

Specifically, it is unclear that this whitespace is also removed from the lines prior to the single line containing the closing quotes. For example, something like the following might be clearer...

In multi-line raw string literals, any whitespace to the left of the closing quotes is removed from all lines in the string.

Also, clarification of the handling of whitespace following the opening quotes would be helpful. While it is somewhat covered in the comments in the code snippet, adding an additional bullet point to the article text might be more helpful.

Finally, while it is apparent (from the comments) that line breaks following the opening quotes are removed, it is unclear if all trailing whitespace (spaces, tabs, etc.) is also removed. Assuming it is removed, it is similarly unclear if this "trimming" behavior extends to subsequent lines of that same string.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 34450

BillWagner commented 1 year ago

Hi @techfan101

One obvious fix is to link to the specification.

However, I'd rather not replicate the spec here. For that reason, this page may (probably should) miss some details. Of the items you mention above, which do you think are common? Which do you think are maybe less needed?

Thanks for the discussion.

Note: Not adding the "needs more info" label because this shouldn't be auto-closed without a response. We need to do something.

techfan101 commented 1 year ago

@BillWagner, thank you for taking the time to consider this request. I had not seen the specification.

While the specification is indeed helpful, I think it may be overkill for casual consumers of this feature :)

I don't suggest significantly altering the article. I think the level of detail already present comes very close to providing enough detail. There are only two minor clarifications that would be helpful.

Regarding the removal of leading whitespace, adding a few words to the end of the existing bullet point should suffice.

Regarding the removal of trailing whitespace, I think a single additional bullet point would suffice. Something like the following, where new text is bolded, should suffice for both:

  • In multi-line raw string literals, any whitespace to the left of the closing quotes is removed from all lines in the string.

  • In multi-line raw string literals, trailing whitespace on the initial line containing the opening quotes is removed. Trailing whitespace on subsequent lines is not altered.

Given the importance of whitespace handling with regard to multi-line string literals, I think this small amount of extra clarification is appropriate.

That said, please fact-check me. I did have a bit of difficulty interpreting the specification. Hopefully, my suggested additions accurately summarize what it specifies.

Thanks again for your time.

BillWagner commented 1 year ago

Thanks @techfan101

That helps a lot. I'll address it this month.