Skip to content

Commit c043438

Browse files
committed
[jnimarshalmethod-gen] Update the types traversal
The previous try to fix #381 didn't work. (adf4c48) The reason is that we don't get the exception when calling `assembly.DefinedTypes`, but later during traversal of the enumerable. So instead of using the `DefinedTypes`, use `GetTypes ()` directly as the exception comes from it. That should hopefuly allow us to handle it here. Related reflection sources: https://github.com/mono/mono/blob/ab3c897d6851ccf75e840d8b767aafa0d0a32d53/mcs/class/corlib/System.Reflection/Assembly.cs#L1023-L1029
1 parent adf4c48 commit c043438

File tree

1 file changed

+7
-5
lines changed
  • tools/jnimarshalmethod-gen

1 file changed

+7
-5
lines changed

tools/jnimarshalmethod-gen/App.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,21 @@ void CreateMarshalMethodAssembly (string path)
245245

246246
PrepareTypeMap (ad.MainModule);
247247

248-
IEnumerable<TypeInfo> types = null;
248+
Type[] types = null;
249249
try {
250-
types = assembly.DefinedTypes;
250+
types = assembly.GetTypes ();
251251
} catch (ReflectionTypeLoadException e) {
252-
types = (IEnumerable<TypeInfo>) e.Types;
252+
types = e.Types;
253253
foreach (var le in e.LoaderExceptions)
254254
Warning ($"Type Load exception{Environment.NewLine}{le}");
255255
}
256256

257-
foreach (var type in types) {
258-
if (type == null)
257+
foreach (var systemType in types) {
258+
if (systemType == null)
259259
continue;
260260

261+
var type = systemType.GetTypeInfo ();
262+
261263
if (matchType) {
262264
var matched = false;
263265

0 commit comments

Comments
 (0)