Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport SuggestedCorrections property on DiagnosticRecord for script based rules #1000
Conversation
|
This looks great and really needed. My comment is not blocking as we can go back and change it later. |
| @@ -28,9 +28,12 @@ function Measure-RequiresRunAsAdministrator | |||
| [System.Management.Automation.Language.ScriptBlockAst] | |||
| $testAst | |||
| ) | |||
| $dr = New-Object ` | |||
| $l=(new-object System.Collections.ObjectModel.Collection["Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.CorrectionExtent"]) | |||
This comment has been minimized.
This comment has been minimized.
JamesWTruher
May 17, 2018
Member
in PowerShellCore tests, we're moving away from using new-object in favor of this:
$l = [System.Collections.ObjectModel.Collection[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.CorrectionExtent]]::new()
$c = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.CorrectionExtent]::new(1,2,3,4,'text','filePath','description')
$null = $l.Add($c)
$dr = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]::new(
"This is help",
$ast.Extent,$PSCmdlet.MyInvocation.InvocationName,
"Warning",
$null,
$null,
$l)
return $dr
which I think is much tidier. I know it's inconsistent, but that's ok - we can go back where we need to.
This comment has been minimized.
This comment has been minimized.
bergmeister
May 17, 2018
•
Author
Collaborator
@JamesWTruher I tried it at first but then had to revert this change because the [Type]::new() constructor was only introduced in version 5, therefore it failed the WMF4 build and we should not document examples that do not work on supported PS versions. Will therefore merge
This comment has been minimized.
This comment has been minimized.
JamesWTruher
May 18, 2018
Member
yah - I thought about this again last night and realized this wouldn't work because of the downlevel requirements. We won't be able to support the modern constructor syntax until we drop support for ps v3/4
LaurentDardenne
commented
Jan 12, 2019
|
For information, these changes are a breaking change, because a priori the 'lookup algorithm' of Powershell does not know how to call the code that worked previously. |
|
@LaurentDardenne I am sorry for that, every release comes with minor breaking changes, which are usually for a better experience, which is to actually propagate the SuggestedCorrections to the end user (one can use them inside vscode now for example). Thank you for your continued and detailed feedback though :)
|
LaurentDardenne
commented
Mar 2, 2019
|
"every release comes with minor breaking changes," |
bergmeister commentedMay 14, 2018
•
edited
PR Summary
Closes #619
Populate property and make it public to keep construction of the object easy.
PR Checklist
Note: Tick the boxes below that apply to this pull request by putting an
xbetween the square brackets. Please mark anything not applicable to this PRNA.WIP:to the beginning of the title and remove the prefix when the PR is ready