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

Formatting DSC Configuration breaks Nodes with where clause #644

Closed
weloytty opened this issue Apr 4, 2017 · 1 comment
Closed

Formatting DSC Configuration breaks Nodes with where clause #644

weloytty opened this issue Apr 4, 2017 · 1 comment
Labels

Comments

@weloytty
Copy link

weloytty commented Apr 4, 2017

System Details

  • Operating system name and version: Win7SP1
  • VS Code version: 1.10.2
  • PowerShell extension version:11.0
  • Output from $PSVersionTable:
    Name Value

PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Copy / paste the below commands into the PowerShell Integrated Terminal, and paste the output here

code -v
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable

[CCNU217908U][C:\sourcecode\Shared\gitprojects\DSC]#code -v
1.10.2
8076a19fdcab7e1fc1707952d652f0bb6c6db331
[CCNU217908U][C:\sourcecode\Shared\gitprojects\DSC]#$pseditor.EditorServicesVersion

Major Minor Build Revision


0 11 0 0

[CCNU217908U][C:\sourcecode\Shared\gitprojects\DSC]#code --list-extensions --show-versions
donjayamanne.python@0.6.0
DotJoshJohnson.xml@1.7.0
EditorConfig.EditorConfig@0.6.2
luggage66.VBScript@0.0.1
ms-vscode.cpptools@0.10.5
ms-vscode.csharp@1.8.1
ms-vscode.PowerShell@0.11.0
searKing.preview-vscode@1.1.4
[CCNU217908U][C:\sourcecode\Shared\gitprojects\DSC]#
[CCNU217908U][C:\sourcecode\Shared\gitprojects\DSC]#$PSVersionTable

Name Value


PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Issue Description

I am experiencing a problem with...

Formatting (via rightclick+Fomat Document) a DSC configuration that has a Where clause in the node name inserts a space between Node $Whatever.Where, which renders the Configuration invalid. I have to manually remove the space between Where and the opening bracket.

Steps to repro:

Create a Configuration, for example:

-- Stick the below text in a text file, named test.ps1 --
Set-StrictMode -Version Latest

Configuration TestConfiguration
{
Import-DscResource -ModuleName PSDesiredStateConfiguration

node $AllNodes.Where{ $_.OS -eq $ConfigurationData.globalWS2012R2Version  }.NodeName
{
    File MyTestDirectory {
        Ensure = "Present"
        Type = "Directory"
        DestinationPath = "C:\test"
    }
}

}

$ConfigurationData = @{
AllNodes = @(
@{
NodeName = "*"
Architecture = "x64"
}
@{
NodeName = "CCNU217908U"
OS = "6.1.7601"

    }
)

globalWin7Version = "6.1.7601"

}

TestConfiguration -ConfigurationData $ConfigurationData
--- Code Above --

Then, run test.ps1 to make sure it works

Next, right click, pick Format Document, and you'll notice that

node $AllNodes.Where{ $_.OS -eq $ConfigurationData.globalWin7Version}.NodeName

will become

node $AllNodes.Where { $_.OS -eq $ConfigurationData.globalWin7Version}.NodeName

which when you run the configuration again, gets you the error
At C:\hold\test.ps1:7 char:75

  • ... odes.Where { $_.OS -eq $ConfigurationData.globalWin7Version}.NodeName
  •                                                             ~~~~~~~~~
    

Undefined DSC resource '.NodeName'. Use Import-DSCResource to import the resource.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ResourceNotDefined

Attached Logs

Follow the instructions in the README
about capturing and sending logs.

@daviwil
Copy link
Contributor

daviwil commented Apr 4, 2017

Luckily we just fixed this issue and we're shipping a new update today :) Closing this for now, let us know if you still run into trouble with it after the 0.12.0 update.

Original issue: PowerShell/PowerShellEditorServices#380

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

No branches or pull requests

2 participants