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..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 @@ -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; @@ -28,33 +29,46 @@ public static ConstructorInvoker Create(ConstructorInfo constructor) return new ConstructorInvoker(runtimeConstructor); } + [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] 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] public object Invoke(object? arg1, object? arg2, object? arg3) { StackAllocatedArguments argStorage = default; 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] public object Invoke(object? arg1, object? arg2, object? arg3, object? arg4) { StackAllocatedArguments argStorage = default; @@ -62,13 +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; } } } 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;