You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Gets the DeclaringType of the first method on the stack whose name matches the specified <paramref name="caller"/>.
83
+
/// </summary>
84
+
/// <param name="caller">The name of the calling method for which the DeclaringType is to be fetched.</param>
85
+
/// <returns>The DeclaringType of the first method on the stack whose name matches the specified <paramref name="caller"/>.</returns>
86
+
internalstaticTypeGetCallingType(stringcaller)
87
+
{
88
+
varcallingMethod=newStackTrace().GetFrames()
89
+
.Select(f =>f.GetMethod())
90
+
.Where(m =>m.Name==caller)
91
+
.FirstOrDefault();
92
+
93
+
if(callingMethod==default(MethodBase))
94
+
{
95
+
thrownewInvalidOperationException($"Unable to determine the containing type of the calling method '{caller}'. Explicitly specify the originating Type.");
96
+
}
97
+
98
+
returncallingMethod.DeclaringType;
99
+
}
80
100
}
81
101
82
102
/// <summary>
@@ -198,11 +218,12 @@ public object this[string index]
198
218
/// marked with the <see cref="ArgumentAttribute"/><see cref="Attribute"/> along with the short and long names and help text.
199
219
/// </summary>
200
220
/// <param name="type">The <see cref="Type"/> for which the matching properties are to be retrieived.</param>
221
+
/// <param name="caller">Internal parameter used to identify the calling method.</param>
201
222
/// <returns>The retrieved collection of <see cref="ArgumentHelp"/>.</returns>
thrownewInvalidOperationException("Error populating arguments; Unable to determine the containing type of Main(). Use Populate(typeof(<class containing main>))");
0 commit comments