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

[PowerShell] Simplify generated code by using here-strings #322

Closed
Josverl opened this issue Aug 18, 2020 · 6 comments · May be fixed by #395
Closed

[PowerShell] Simplify generated code by using here-strings #322

Josverl opened this issue Aug 18, 2020 · 6 comments · May be fixed by #395
Labels
codegen feature Feature request

Comments

@Josverl
Copy link

Josverl commented Aug 18, 2020

The current implementation of the PowerShell generator requires a lot of escapes ``" for each quote and linefeed
this makes the generated core hard to read and change and verify.

Describe the solution you'd like
get rid of the escapes by using a PowerShell here-strings @" .... "@
I would preferer the double-quoted version as that will support variable replacement.

Proposed use of here-string:

$body = @"
{
       "type":"message",
       "attachments":[
          {
             "contentType":"application/vnd.microsoft.card.adaptive",
             "contentUrl":null,
             "content":
    // insert card here          
    {
      "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
      "type": "AdaptiveCard",
      "version": "1.0",
      "body": [
        {
          "type": "TextBlock",
          "text": "Publish Adaptive Card schema",
          "weight": "bolder",
          "size": "medium"
        }
    ]
    //up to here 
          }
       ]
    }
"@

Current use of many escapes:

$body = "{
`n   `"type`":`"message`",
`n   `"attachments`":[
`n      {
`n         `"contentType`":`"application/vnd.microsoft.card.adaptive`",
`n         `"contentUrl`":null,
`n         `"content`":
`n// insert card here          
`n{
`n  `"$schema`": `"http://adaptivecards.io/schemas/adaptive-card.json`",
`n  `"type`": `"AdaptiveCard`",
`n  `"version`": `"1.0`",
`n  `"body`": [
`n    {
`n      `"type`": `"TextBlock`",
`n      `"text`": `"Publish Adaptive Card schema`",
`n      `"weight`": `"bolder`",
`n      `"size`": `"medium`"
`n    }
`n]
`n
`n//up to here 
`n
`n      }
`n   ]
`n}"
@umeshp7 umeshp7 added the feature Feature request label Sep 22, 2020
@karmanya007
Copy link

@umeshp7 That means that there would be no use of sanitize function, right?

@karmanya007
Copy link

@umeshp7 PR opened. Please review.

@karmanya007
Copy link

karmanya007 commented Oct 24, 2020

@umeshp7 I think the travis tests need to be updated.

travisError

@umeshp7
Copy link
Member

umeshp7 commented Oct 25, 2020

@karmanya007 This is the unit test inside Powershell. You might have to update that.

@dhwaneetbhatt
Copy link
Contributor

This is fixed in the latest version v10.12. Closing this issue. Fixed as part of #679.

@Josverl
Copy link
Author

Josverl commented Apr 5, 2023

Thanks, has been a long wait, but thanks for following through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen feature Feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants