Skip to content

Custom class type qualifiers break things #51

Description

@Nissplus

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions