I was experimenting with the beautifier on existing codebase, and it seems to break class definitions. Here's an example:
Input
class TestClass {
[string] $aa
}
$inst = [TestClass]::new()
Used command
> Edit-DTWBeautifyScript ./test.ps1 -Verbose
VERBOSE: Reading source: .../test.ps1
VERBOSE: Tokenizing script content
VERBOSE: Migrate source content to destination format
VERBOSE: Write destination file: .../test.ps1
VERBOSE: Finished in 0.149 seconds.
Expected output
class TestClass {
[string]$aa
}
$inst = [testclass]::new()
Actual output
class [testclass]{
[string]$aa
}
$inst = [testclass]::new()
Of course, our test script breaks:
./test.ps1
At .../test.ps1:1 char:6
+ class [testclass]{
+ ~
Missing name after class keyword.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingNameAfterKeyword
Additional info
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.1
PSEdition Core
GitCommitId v6.1.0-preview.1
OS Linux 4.13.9-300.fc27.x86_64 #1 SMP Mon Oct 23 13:41:58 UTC 2017
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> Get-Module *Beautifier*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.2.3 PowerShell-Beautifier {Add-DTWFileEncodingByteOrderMarker, Compare-DTWFiles, Compare-DTWFilesIgnoringBOM, Comp...
I was experimenting with the beautifier on existing codebase, and it seems to break class definitions. Here's an example:
Input
Used command
Expected output
Actual output
Of course, our test script breaks:
Additional info
This https://github.com/DTW-DanWard/PowerShell-Beautifier/blob/master/src/DTW.PS.Beautifier.Main.psm1#L910 seems like a candidate for the source of the issue, but I don't know the codebase.