From 69030810bef83e3f26a483f2350a0da29ea1270d Mon Sep 17 00:00:00 2001 From: Steve Harter Date: Thu, 27 Jul 2023 16:15:01 -0500 Subject: [PATCH 1/3] Add [DebuggerGuidedStepThrough] to new invoker methods --- .../src/System/Reflection/ConstructorInvoker.cs | 6 ++++++ .../src/System/Reflection/MethodInvoker.cs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs index f49ba0fa90983f..e8497f03f777bc 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs @@ -28,16 +28,19 @@ public static ConstructorInvoker Create(ConstructorInfo constructor) return new ConstructorInvoker(runtimeConstructor); } + [DebuggerGuidedStepThrough] public object Invoke() { return _methodBaseInvoker.CreateInstanceWithFewArgs(new Span()); } + [DebuggerGuidedStepThrough] public object Invoke(object? arg1) { return _methodBaseInvoker.CreateInstanceWithFewArgs(new Span(ref arg1)); } + [DebuggerGuidedStepThrough] public object Invoke(object? arg1, object? arg2) { StackAllocatedArguments argStorage = default; @@ -46,6 +49,7 @@ public object Invoke(object? arg1, object? arg2) return _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(2)); } + [DebuggerGuidedStepThrough] public object Invoke(object? arg1, object? arg2, object? arg3) { StackAllocatedArguments argStorage = default; @@ -55,6 +59,7 @@ public object Invoke(object? arg1, object? arg2, object? arg3) return _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(3)); } + [DebuggerGuidedStepThrough] public object Invoke(object? arg1, object? arg2, object? arg3, object? arg4) { StackAllocatedArguments argStorage = default; @@ -65,6 +70,7 @@ public object Invoke(object? arg1, object? arg2, object? arg3, object? arg4) return _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(4)); } + [DebuggerGuidedStepThrough] public object Invoke(Span arguments) { diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs index 93efbe1f0470f4..82951425e37093 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs @@ -41,6 +41,7 @@ public static MethodInvoker Create(MethodBase method) throw new ArgumentException(SR.Argument_MustBeRuntimeMethod, nameof(method)); } + [DebuggerGuidedStepThrough] public object? Invoke(object? obj) { object? result = _methodBaseInvoker.InvokeDirectWithFewArgs(obj, new Span()); @@ -48,6 +49,7 @@ public static MethodInvoker Create(MethodBase method) return result; } + [DebuggerGuidedStepThrough] public object? Invoke(object? obj, object? arg1) { object? result = _methodBaseInvoker.InvokeDirectWithFewArgs(obj, new Span(ref arg1)); @@ -55,6 +57,7 @@ public static MethodInvoker Create(MethodBase method) return result; } + [DebuggerGuidedStepThrough] public object? Invoke(object? obj, object? arg1, object? arg2) { StackAllocatedArguments argStorage = default; @@ -66,6 +69,7 @@ public static MethodInvoker Create(MethodBase method) return result; } + [DebuggerGuidedStepThrough] public object? Invoke(object? obj, object? arg1, object? arg2, object? arg3) { StackAllocatedArguments argStorage = default; @@ -78,6 +82,7 @@ public static MethodInvoker Create(MethodBase method) return result; } + [DebuggerGuidedStepThrough] public object? Invoke(object? obj, object? arg1, object? arg2, object? arg3, object? arg4) { StackAllocatedArguments argStorage = default; From 8540dc5bd04a8822dca3e93110168c48c5ce5377 Mon Sep 17 00:00:00 2001 From: Steve Harter Date: Fri, 28 Jul 2023 09:50:28 -0500 Subject: [PATCH 2/3] Add using statement --- .../src/System/Reflection/ConstructorInvoker.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs index e8497f03f777bc..4bfccd21287491 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Internal.Reflection.Core.Execution; +using System.Diagnostics; using System.Reflection.Runtime.MethodInfos; using static System.Reflection.DynamicInvokeInfo; From 8db9f4e93f83fff45736b863700de0233e6658f8 Mon Sep 17 00:00:00 2001 From: Steve Harter Date: Mon, 31 Jul 2023 16:33:34 -0500 Subject: [PATCH 3/3] Add PreviousCallContainsDebuggerStepInCode() --- .../System/Reflection/ConstructorInvoker.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs index 4bfccd21287491..13eadbffb4580e 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs @@ -32,13 +32,17 @@ public static ConstructorInvoker Create(ConstructorInfo constructor) [DebuggerGuidedStepThrough] public object Invoke() { - return _methodBaseInvoker.CreateInstanceWithFewArgs(new Span()); + object result = _methodBaseInvoker.CreateInstanceWithFewArgs(new Span()); + DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); + return result; } [DebuggerGuidedStepThrough] public object Invoke(object? arg1) { - return _methodBaseInvoker.CreateInstanceWithFewArgs(new Span(ref arg1)); + object result = _methodBaseInvoker.CreateInstanceWithFewArgs(new Span(ref arg1)); + DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); + return result; } [DebuggerGuidedStepThrough] @@ -47,7 +51,9 @@ public object Invoke(object? arg1, object? arg2) StackAllocatedArguments argStorage = default; argStorage._args.Set(0, arg1); argStorage._args.Set(1, arg2); - return _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(2)); + object result = _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(2)); + DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); + return result; } [DebuggerGuidedStepThrough] @@ -57,7 +63,9 @@ public object Invoke(object? arg1, object? arg2, object? arg3) argStorage._args.Set(0, arg1); argStorage._args.Set(1, arg2); argStorage._args.Set(2, arg3); - return _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(3)); + object result = _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(3)); + DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); + return result; } [DebuggerGuidedStepThrough] @@ -68,14 +76,17 @@ public object Invoke(object? arg1, object? arg2, object? arg3, object? arg4) argStorage._args.Set(1, arg2); argStorage._args.Set(2, arg3); argStorage._args.Set(3, arg4); - return _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(4)); + object result = _methodBaseInvoker.CreateInstanceWithFewArgs(argStorage._args.AsSpan(4)); + DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); + return result; } [DebuggerGuidedStepThrough] public object Invoke(Span arguments) { - - return _methodBaseInvoker.CreateInstance(arguments); + object result = _methodBaseInvoker.CreateInstance(arguments); + DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); + return result; } } }