Skip to content

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

@Josverl

Description

@Josverl

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}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions