MethodsAndPractices / vsteam

PowerShell module for accessing Azure DevOps Services and Azure DevOps Server (formerly VSTS or TFS)
https://methodsandpractices.github.io/vsteam-docs/
MIT License
445 stars 155 forks source link

MergeFile.ps1 tricked by "using" in a comment. #319

Closed jhoneill closed 4 years ago

jhoneill commented 4 years ago

Steps to reproduce

if a class file has a comment like this

<#
blah blah
we do this using blah blah
blah blah 
#>

when the module is built, merge file matches on using and will put "we do this "into the output file

This is fixed by changing two regexes in MergeFile.

At line 189 $matches = $fileContents | Select-String '^\s*using' And at line 202 $newFileContents = ($fileContents -replace '^\s*using.*$', '')

The first for "any line starting with any white space followed by "using" and the second for "Any line starting with using, all the way to the end of the line.

DarqueWarrior commented 4 years ago

All classes are being moved to C#. The next version 7.0 will no longer have any PowerShell Class files.

jhoneill commented 4 years ago

So you're going to take the logic for "using" out of mergefile ? The problem is the old logic finds false-positives and moves (e.g). a line from the middle of a comment block - which won't be valid syntactically.