Skip to content

Update here string syntax#17483

Open
MartinGC94 wants to merge 9 commits intoPowerShell:masterfrom
MartinGC94:NewHere-stringSyntax
Open

Update here string syntax#17483
MartinGC94 wants to merge 9 commits intoPowerShell:masterfrom
MartinGC94:NewHere-stringSyntax

Conversation

@MartinGC94
Copy link
Copy Markdown
Contributor

@MartinGC94 MartinGC94 commented Jun 4, 2022

PR Summary

This updates the here string syntax to support a variable amount of quote characters in the header, which determines what the footer should look like. This enables the user to write nested here strings like so:

Invoke-VMScript -ScriptText @''
    Set-Content C:\Temp.txt -Value @'
    <Text>
'@
''@

Additionally, adding 2 or more quotes to the here string header enables the user to indent the footer like this:

function MyFunction
{
    @''
    Hello World
    ''@
}

The indentation of the footer determines which column the lines start at. For example, in the previous example the content of the here string is Hello World and not Hello World because both the footer and the text is indented by 4 spaces.
For more details see the related RFC : PowerShell/PowerShell-RFC#343 or the linked issue.

PR Context

Fixes #2337

PR Checklist

@MartinGC94 MartinGC94 requested a review from daxian-dbw as a code owner June 4, 2022 18:54
@ghost ghost assigned TravisEz13 Jun 4, 2022
@ghost ghost added the Review - Needed The PR is being reviewed label Jun 12, 2022
@ghost
Copy link
Copy Markdown

ghost commented Jun 12, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@MartinGC94 MartinGC94 changed the title WIP: Add indented here-string and single line here-string Add indented here-string and single line here-string Jul 25, 2022
@ghost ghost removed the Review - Needed The PR is being reviewed label Aug 5, 2022
@TravisEz13 TravisEz13 removed their assignment Aug 5, 2022
@ghost ghost added the Review - Needed The PR is being reviewed label Aug 13, 2022
@ghost
Copy link
Copy Markdown

ghost commented Aug 13, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@iSazonov
Copy link
Copy Markdown
Collaborator

Since C# got this I believe we need follow C#.

@ghost ghost removed the Review - Needed The PR is being reviewed label Dec 20, 2022
@MartinGC94
Copy link
Copy Markdown
Contributor Author

@iSazonov PowerShell is not C#. We can take all the good parts from C# but there's no need to take the bad parts as well. The C# docs for raw strings mention this:

If you need to start or end a raw string literal with quote characters, use the multi-line format

why would we want to add the same limitation here if we can avoid it?

@iSazonov
Copy link
Copy Markdown
Collaborator

Since this was not in C# but is now, it will raise questions for users. That is why it should be discussed.

@ghost ghost added the Review - Needed The PR is being reviewed label Dec 27, 2022
@ghost
Copy link
Copy Markdown

ghost commented Dec 27, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@daxian-dbw
Copy link
Copy Markdown
Member

daxian-dbw commented Jan 23, 2023

@MartinGC94 Sorry for the delay on responding. The Engine WG discussed this PR briefly in our last meeting, and we agreed that this would be a nice improvement to have. However, since it's a language change, an RFC would be required along with this PR. Can you please submit an RFC about this topic to the https://github.com/PowerShell/PowerShell-RFC repo? Thanks!

@ghost ghost removed the Review - Needed The PR is being reviewed label Jan 23, 2023
@MartinGC94
Copy link
Copy Markdown
Contributor Author

@daxian-dbw Done. See: PowerShell/PowerShell-RFC#343

@ghost ghost added the Review - Needed The PR is being reviewed label Jan 31, 2023
@ghost
Copy link
Copy Markdown

ghost commented Jan 31, 2023

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@SteveL-MSFT SteveL-MSFT added WG-Language parser, language semantics WG-NeedsReview Needs a review by the labeled Working Group labels Jul 5, 2023
@MartinGC94 MartinGC94 changed the title Add indented here-string and single line here-string WIP: Add indented here-string and single line here-string Aug 10, 2023
MartinGC94 and others added 2 commits August 11, 2023 01:00
Trim spaces based on the footer line, rather than the shortest line.
Remove single line here string support
@MartinGC94 MartinGC94 changed the title WIP: Add indented here-string and single line here-string Update here string syntax Aug 13, 2023
@pull-request-quantifier-deprecated
Copy link
Copy Markdown

This PR has 384 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Large
Size       : +246 -138
Percentile : 78.4%

Total files changed: 3

Change summary by file extension:
.cs : +168 -137
.resx : +9 -0
.ps1 : +69 -1

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Large Review - Needed The PR is being reviewed WG-Language parser, language semantics WG-NeedsReview Needs a review by the labeled Working Group

Projects

None yet

Development

Successfully merging this pull request may close these issues.

here string syntax

5 participants