File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed
src/System.Management.Automation/engine/parser
test/powershell/Language/Scripting/Debugging Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -642,7 +642,7 @@ internal static class CachedReflectionInfo
642
642
643
643
internal static readonly MethodInfo ArgumentTransformationAttribute_Transform =
644
644
typeof ( ArgumentTransformationAttribute ) . GetMethod ( nameof ( ArgumentTransformationAttribute . Transform ) , InstancePublicFlags ) ;
645
-
645
+
646
646
internal static readonly MethodInfo MemberInvocationLoggingOps_LogMemberInvocation =
647
647
typeof ( MemberInvocationLoggingOps ) . GetMethod ( nameof ( MemberInvocationLoggingOps . LogMemberInvocation ) , StaticFlags ) ;
648
648
}
@@ -5617,7 +5617,9 @@ public object VisitReturnStatement(ReturnStatementAst returnStatementAst)
5617
5617
return Expression . Block ( returnValue , returnExpr ) ;
5618
5618
}
5619
5619
5620
- return returnExpr ;
5620
+ return Expression . Block (
5621
+ UpdatePosition ( returnStatementAst ) ,
5622
+ returnExpr ) ;
5621
5623
}
5622
5624
5623
5625
public object VisitExitStatement ( ExitStatementAst exitStatementAst )
Original file line number Diff line number Diff line change @@ -331,6 +331,50 @@ elseif (Test-Path $PSCommandPath)
331
331
$Breakpoint.HitCount | Should - Be $HitCount
332
332
}
333
333
}
334
+
335
+ Context " Break point on return should hit" {
336
+ BeforeAll {
337
+ $return_script_1 = @'
338
+ return
339
+ '@
340
+ $return_script_2 = @'
341
+ return 10
342
+ '@
343
+ $return_script_3 = @'
344
+ trap {
345
+ 'statement to ignore trap registration sequence point'
346
+ return
347
+ }
348
+
349
+ throw
350
+ '@
351
+
352
+ $ReturnScript_1 = Setup - PassThru - File ReturnScript_1.ps1 - Content $return_script_1
353
+ $bp_1 = Set-PSBreakpoint - Script $ReturnScript_1 - Line 1 - Action { continue }
354
+
355
+ $ReturnScript_2 = Setup - PassThru - File ReturnScript_2.ps1 - Content $return_script_2
356
+ $bp_2 = Set-PSBreakpoint - Script $ReturnScript_2 - Line 1 - Action { continue }
357
+
358
+ $ReturnScript_3 = Setup - PassThru - File ReturnScript_3.ps1 - Content $return_script_3
359
+ $bp_3 = Set-PSBreakpoint - Script $ReturnScript_3 - Line 3 - Action { continue }
360
+
361
+ $testCases = @ (
362
+ @ { Name = " return without pipeline should be hit once" ; Path = $ReturnScript_1 ; Breakpoint = $bp_1 ; HitCount = 1 }
363
+ @ { Name = " return with pipeline should be hit once" ; Path = $ReturnScript_2 ; Breakpoint = $bp_2 ; HitCount = 1 }
364
+ @ { Name = " return from trap should be hit once" ; Path = $ReturnScript_3 ; Breakpoint = $bp_3 ; HitCount = 1 }
365
+ )
366
+ }
367
+
368
+ AfterAll {
369
+ Get-PSBreakpoint - Script $ReturnScript_1 , $ReturnScript_2 , $ReturnScript_3 | Remove-PSBreakpoint
370
+ }
371
+
372
+ It " Return statement <Name>" - TestCases $testCases {
373
+ param ($Path , $Breakpoint , $HitCount )
374
+ $null = & $Path
375
+ $Breakpoint.HitCount | Should - Be $HitCount
376
+ }
377
+ }
334
378
}
335
379
336
380
Describe " It should be possible to reset runspace debugging" - Tag " Feature" {
You can’t perform that action at this time.
0 commit comments