Skip to content

Commit b0a7c57

Browse files
author
Kapil Borle
committed
Add a file that contains helper functions for tests
1 parent eb05a8e commit b0a7c57

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Function Get-ExtentText
2+
{
3+
Param(
4+
[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.CorrectionExtent] $violation,
5+
[string] $scriptPath
6+
)
7+
$scriptContent = Get-Content -Path $scriptPath
8+
$start = [System.Management.Automation.Language.ScriptPosition]::new($scriptPath, $violation.StartLineNumber, $violation.StartColumnNumber, $scriptContent[$violation.StartLineNumber - 1])
9+
$end = [System.Management.Automation.Language.ScriptPosition]::new($scriptPath, $violation.EndLineNumber, $violation.EndColumnNumber, $scriptContent[$violation.EndLineNumber - 1])
10+
$extent = [System.Management.Automation.Language.ScriptExtent]::new($start, $end)
11+
return($extent.Text)
12+
}
13+
14+
Export-ModuleMember -Function Get-ExtentText

0 commit comments

Comments
 (0)