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

Custom class type qualifiers break things #51

Open
Nissplus opened this issue Nov 25, 2019 · 0 comments
Open

Custom class type qualifiers break things #51

Nissplus opened this issue Nov 25, 2019 · 0 comments

Comments

@Nissplus
Copy link

Nissplus commented Nov 25, 2019

If the file being processed refers to a custom type that is defined elsewhere, the beautifier barfs.
For example:
(as used in Microsoft's AzSK framework code)
in Constants.ps1
class Constants { .. }
in ConfigurationHelper.ps1
$rootConfigPath = [Constants]::AzSKAppFolderPath ;
Then edit-dtwBeautifyScript -Verbose -sourcepath ./src/AzSK.Framework/Helpers/ConfigurationHelper.ps1 -DestinationPath /tmp/foo.ps1
will produce many errors (see below) and no output

Hacky work-around: If I add this line to DTW.PS.Beautifier.Main.psm1 line 420
$Err = $Err | where { -not $_.Message.StartsWith("Unable to find type")}
Then it works better.


A few errors generated:
Invoke-TokenizeSourceScriptContent : An error occurred; is there invalid PowerShell or some formatting / syntax issue in the script? See error record below.
At ~/.local/share/powershell/Modules/PowerShell-Beautifier/1.2.5/src/DTW.PS.Beautifier.Main.psm1:1332 char:5

Invoke-TokenizeSourceScriptContent -EV Err

CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-TokenizeSourceScriptContent
 
Invoke-TokenizeSourceScriptContent : Unable to find type [Constants]. Content: Constants, line: 18, column: 22
At ~/.local/share/powershell/Modules/PowerShell-Beautifier/1.2.5/src/DTW.PS.Beautifier.Main.psm1:1332 char:5
Invoke-TokenizeSourceScriptContent -EV Err

CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-TokenizeSourceScriptContent

Invoke-TokenizeSourceScriptContent : Unable to find type [Constants]. Content: Constants, line: 80, column: 28
At ~/.local/share/powershell/Modules/PowerShell-Beautifier/1.2.5/src/DTW.PS.Beautifier.Main.psm1:1332 char:5

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

No branches or pull requests

1 participant