Skip to content

Commit 102ae78

Browse files
authored
[browser][debugger] Tests bind_static_method error propagation (#97816)
1 parent 5cd9eb8 commit 102ae78

File tree

1 file changed

+160
-32
lines changed

1 file changed

+160
-32
lines changed

src/mono/browser/debugger/tests/debugger-test/BindStaticMethod.cs

Lines changed: 160 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -102,113 +102,241 @@ public static string GetSignature([JSMarshalAs<JSType.Any>()] object methodInfo)
102102
[JSExport]
103103
public static void Invoke_Void([JSMarshalAs<JSType.Any>()] object methodInfo)
104104
{
105-
var method = (MethodInfo)methodInfo;
106-
method.Invoke(null, null);
105+
try
106+
{
107+
var method = (MethodInfo)methodInfo;
108+
method.Invoke(null, null);
109+
}
110+
catch (TargetInvocationException tie)
111+
{
112+
if (tie.InnerException != null) throw tie.InnerException;
113+
throw;
114+
}
107115
}
108116

109117
[JSExport]
110118
public static Task Invoke_Task([JSMarshalAs<JSType.Any>()] object methodInfo)
111119
{
112-
var method = (MethodInfo)methodInfo;
113-
return (Task)method.Invoke(null, null);
120+
try
121+
{
122+
var method = (MethodInfo)methodInfo;
123+
return (Task)method.Invoke(null, null);
124+
}
125+
catch (TargetInvocationException tie)
126+
{
127+
if (tie.InnerException != null) throw tie.InnerException;
128+
throw;
129+
}
114130
}
115131

116132
[JSExport]
117133
public static string Invoke_String([JSMarshalAs<JSType.Any>()] object methodInfo)
118134
{
119-
var method = (MethodInfo)methodInfo;
120-
return (string)method.Invoke(null, null);
135+
try
136+
{
137+
var method = (MethodInfo)methodInfo;
138+
return (string)method.Invoke(null, null);
139+
}
140+
catch (TargetInvocationException tie)
141+
{
142+
if (tie.InnerException != null) throw tie.InnerException;
143+
throw;
144+
}
121145
}
122146

123147
[JSExport]
124148
public static void Invoke_Boolean_Void([JSMarshalAs<JSType.Any>()] object methodInfo, bool p1)
125149
{
126-
var method = (MethodInfo)methodInfo;
127-
method.Invoke(null, new object[] { p1 });
150+
try
151+
{
152+
var method = (MethodInfo)methodInfo;
153+
method.Invoke(null, new object[] { p1 });
154+
}
155+
catch (TargetInvocationException tie)
156+
{
157+
if (tie.InnerException != null) throw tie.InnerException;
158+
throw;
159+
}
128160
}
129161

130162
[JSExport]
131163
public static Task Invoke_Boolean_Task([JSMarshalAs<JSType.Any>()] object methodInfo, bool p1)
132164
{
133-
var method = (MethodInfo)methodInfo;
134-
return (Task)method.Invoke(null, new object[] { p1 });
165+
try
166+
{
167+
var method = (MethodInfo)methodInfo;
168+
return (Task)method.Invoke(null, new object[] { p1 });
169+
}
170+
catch (TargetInvocationException tie)
171+
{
172+
if (tie.InnerException != null) throw tie.InnerException;
173+
throw;
174+
}
135175
}
136176

137177
[JSExport]
138178
public static void Invoke_Int32_Void([JSMarshalAs<JSType.Any>()] object methodInfo, int p1)
139179
{
140-
var method = (MethodInfo)methodInfo;
141-
method.Invoke(null, new object[] { p1 });
180+
try
181+
{
182+
var method = (MethodInfo)methodInfo;
183+
method.Invoke(null, new object[] { p1 });
184+
}
185+
catch (TargetInvocationException tie)
186+
{
187+
if (tie.InnerException != null) throw tie.InnerException;
188+
throw;
189+
}
142190
}
143191

144192
[JSExport]
145193
public static void Invoke_Int32_Int32_Void([JSMarshalAs<JSType.Any>()] object methodInfo, int p1, int p2)
146194
{
147-
var method = (MethodInfo)methodInfo;
148-
method.Invoke(null, new object[] { p1, p2 });
195+
try
196+
{
197+
var method = (MethodInfo)methodInfo;
198+
method.Invoke(null, new object[] { p1, p2 });
199+
}
200+
catch (TargetInvocationException tie)
201+
{
202+
if (tie.InnerException != null) throw tie.InnerException;
203+
throw;
204+
}
149205
}
150206

151207
[JSExport]
152208
public static void Invoke_Int32_Int32_Int32_Void([JSMarshalAs<JSType.Any>()] object methodInfo, int p1, int p2, int p3)
153209
{
154-
var method = (MethodInfo)methodInfo;
155-
method.Invoke(null, new object[] { p1, p2, p3 });
210+
try
211+
{
212+
var method = (MethodInfo)methodInfo;
213+
method.Invoke(null, new object[] { p1, p2, p3 });
214+
}
215+
catch (TargetInvocationException tie)
216+
{
217+
if (tie.InnerException != null) throw tie.InnerException;
218+
throw;
219+
}
156220
}
157221

158222
[JSExport]
159223
public static int Invoke_Int32([JSMarshalAs<JSType.Any>()] object methodInfo)
160224
{
161-
var method = (MethodInfo)methodInfo;
162-
return (int)method.Invoke(null, null);
225+
try
226+
{
227+
var method = (MethodInfo)methodInfo;
228+
return (int)method.Invoke(null, null);
229+
}
230+
catch (TargetInvocationException tie)
231+
{
232+
if (tie.InnerException != null) throw tie.InnerException;
233+
throw;
234+
}
163235
}
164236

165237
[JSExport]
166238
public static int Invoke_Int32_Int32([JSMarshalAs<JSType.Any>()] object methodInfo, int p1)
167239
{
168-
var method = (MethodInfo)methodInfo;
169-
return (int)method.Invoke(null, new object[] { p1 });
240+
try
241+
{
242+
var method = (MethodInfo)methodInfo;
243+
return (int)method.Invoke(null, new object[] { p1 });
244+
}
245+
catch (TargetInvocationException tie)
246+
{
247+
if (tie.InnerException != null) throw tie.InnerException;
248+
throw;
249+
}
170250
}
171251

172252
[JSExport]
173253
public static int Invoke_Int32_Int32_Int32([JSMarshalAs<JSType.Any>()] object methodInfo, int p1, int p2)
174254
{
175-
var method = (MethodInfo)methodInfo;
176-
return (int)method.Invoke(null, new object[] { p1, p2 });
255+
try
256+
{
257+
var method = (MethodInfo)methodInfo;
258+
return (int)method.Invoke(null, new object[] { p1, p2 });
259+
}
260+
catch (TargetInvocationException tie)
261+
{
262+
if (tie.InnerException != null) throw tie.InnerException;
263+
throw;
264+
}
177265
}
178266

179267
[JSExport]
180268
public static void Invoke_String_Void([JSMarshalAs<JSType.Any>()] object methodInfo, string p1)
181269
{
182-
var method = (MethodInfo)methodInfo;
183-
method.Invoke(null, new object[] { p1 });
270+
try
271+
{
272+
var method = (MethodInfo)methodInfo;
273+
method.Invoke(null, new object[] { p1 });
274+
}
275+
catch (TargetInvocationException tie)
276+
{
277+
if (tie.InnerException != null) throw tie.InnerException;
278+
throw;
279+
}
184280
}
185281

186282
[JSExport]
187283
public static void Invoke_String_String_Void([JSMarshalAs<JSType.Any>()] object methodInfo, string p1, string p2)
188284
{
189-
var method = (MethodInfo)methodInfo;
190-
method.Invoke(null, new object[] { p1, p2 });
285+
try
286+
{
287+
var method = (MethodInfo)methodInfo;
288+
method.Invoke(null, new object[] { p1, p2 });
289+
}
290+
catch (TargetInvocationException tie)
291+
{
292+
if (tie.InnerException != null) throw tie.InnerException;
293+
throw;
294+
}
191295
}
192296

193297
[JSExport]
194298
public static void Invoke_String_String_String_String_Void([JSMarshalAs<JSType.Any>()] object methodInfo, string p1, string p2, string p3, string p4)
195299
{
196-
var method = (MethodInfo)methodInfo;
197-
method.Invoke(null, new object[] { p1, p2, p3, p4 });
300+
try
301+
{
302+
var method = (MethodInfo)methodInfo;
303+
method.Invoke(null, new object[] { p1, p2, p3, p4 });
304+
}
305+
catch (TargetInvocationException tie)
306+
{
307+
if (tie.InnerException != null) throw tie.InnerException;
308+
throw;
309+
}
198310
}
199311

200312
[JSExport]
201313
public static string Invoke_String_String_String([JSMarshalAs<JSType.Any>()] object methodInfo, string p1, string p2)
202314
{
203-
var method = (MethodInfo)methodInfo;
204-
return (string)method.Invoke(null, new object[] { p1, p2 });
315+
try
316+
{
317+
var method = (MethodInfo)methodInfo;
318+
return (string)method.Invoke(null, new object[] { p1, p2 });
319+
}
320+
catch (TargetInvocationException tie)
321+
{
322+
if (tie.InnerException != null) throw tie.InnerException;
323+
throw;
324+
}
205325
}
206326

207327
[JSExport]
208328
public static void Invoke_String_String_String_String_String_String_String_String_Void([JSMarshalAs<JSType.Any>()] object methodInfo, string p1, string p2, string p3, string p4, string p5, string p6, string p7, string p8)
209329
{
210-
var method = (MethodInfo)methodInfo;
211-
method.Invoke(null, new object[] { p1, p2, p3, p4, p5, p6, p7, p8 });
330+
try
331+
{
332+
var method = (MethodInfo)methodInfo;
333+
method.Invoke(null, new object[] { p1, p2, p3, p4, p5, p6, p7, p8 });
334+
}
335+
catch (TargetInvocationException tie)
336+
{
337+
if (tie.InnerException != null) throw tie.InnerException;
338+
throw;
339+
}
212340
}
213341

214342
[StructLayout(LayoutKind.Explicit)]

0 commit comments

Comments
 (0)