-
Notifications
You must be signed in to change notification settings - Fork 508
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 partial / dot sourced ps1 dsc scripts #1583
Comments
Hi @chrisshearing, thanks for opening such a detailed issue. Our formatting is handled by the PSScriptAnalyzer project. It looks like a similar request already exists here: PowerShell/PSScriptAnalyzer#1029. I could imagine this being tricky to implement though, since the context to know that the dot-sourced file represents a DSC resource only exists in the file with the configuration. But it sounds like a generic alignment rule would suffice there. Have a read through that PSScriptAnalyzer issue and if it doesn't suit you, the best solution is probably to open a new PSScriptAnalyzer issue in that repo. |
Hi @rjmholt , thanks for your reply and information on where I should be directing the issue report. I didn't think to check the PSScriptAnalyzer project, but it's obvious now you've mentioned it, so apologies for that! I think my issue is slightly different from the one you found and linked, the DSC resource default behaviour should be to align the contents, however it's not registering it's a DSC resource because it's only a partial config, I shall copy most of this and open a new issue on the PSScriptAnalyzer project, linking back to here. Thanks again, |
@chrisshearing No need to apologise for anything -- it's an implementation detail. But that's the point of discussing it in the issue I suppose. Anyway, I've updated the issue templates to be more explicit. As I say, I'm not sure how simple this will be, since the only way for PSSA to know that your dot-sourced file is a DSC resource is to traverse the dot-source in the parent file (your DSC resource could just be another function call). But it seems to me like a generic formatter alignment rule would work quite well here anyway. |
I'm going to close this here due to the specificity of the issue and it being handled by PSSA. If it transpires that we need to change something, we can reopen. |
@rjmholt I answered in the PSSA repo but just FYI: |
Issue Description
I'm currently creating DSC Resource modules to apply settings in our environment, I'm breaking down the actual settings to individual files to make managing the settings easier and to have an easy structure of those settings.
The issue is that the formatter is not performing the align dsc resource / hash table function on the files to import.
It's not really relevant but i'm using the following code in my policy.schema.psm1 file
each individual file then looks like this:
DisableLocalMachineRunOnce.ps1
most of the formatting works, but not the alignment, if I add a configuration section around the code it works, but that would break my import.
You can easily see the difference by creating a new .ps1 file, using the above code, the second example will auto-format the alignment in the dsc resource, the first won't.
If you need anything else, I'm happy to provide it!
Attached Logs
I've not attached logs - problem seems easily reproducible, can add later if really needed.
Environment Information
Visual Studio Code
PowerShell Information
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
The text was updated successfully, but these errors were encountered: