@nativescript/windows 0.1.0-alpha.41 → 0.1.0-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -53,7 +53,7 @@ public static partial class Bridge
|
|
|
53
53
|
var typeName = r.ReadString16();
|
|
54
54
|
var assembly = r.ReadString16();
|
|
55
55
|
var type = ResolveType(NullIfEmpty(assembly), typeName)
|
|
56
|
-
?? throw new TypeLoadException($"Type not found: {typeName}");
|
|
56
|
+
?? throw new TypeLoadException($"Type not found: {typeName} (assembly: {assembly})");
|
|
57
57
|
return BuildMembersResult(type);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -79,7 +79,7 @@ public static partial class Bridge
|
|
|
79
79
|
var typeNameS = r.ReadString16();
|
|
80
80
|
var assemblyS = r.ReadString16();
|
|
81
81
|
var typeS = ResolveType(NullIfEmpty(assemblyS), typeNameS)
|
|
82
|
-
?? throw new TypeLoadException($"Type not found: {typeNameS}");
|
|
82
|
+
?? throw new TypeLoadException($"Type not found: {typeNameS} (assembly: {assemblyS})");
|
|
83
83
|
|
|
84
84
|
if (op == 0x03) // constructor
|
|
85
85
|
{
|
|
@@ -36,7 +36,7 @@ public static partial class Bridge
|
|
|
36
36
|
else
|
|
37
37
|
{
|
|
38
38
|
type = ResolveType(req.Assembly, req.TypeName)
|
|
39
|
-
?? throw new TypeLoadException($"Type not found: {req.TypeName}");
|
|
39
|
+
?? throw new TypeLoadException($"Type not found: {req.TypeName} (assembly: {req.Assembly})");
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
if (method == "__members__")
|
|
@@ -261,19 +261,75 @@ public static partial class Bridge
|
|
|
261
261
|
|
|
262
262
|
private static Type? ResolveTypeCore(string? assemblyName, string? typeName)
|
|
263
263
|
{
|
|
264
|
+
if (string.IsNullOrEmpty(typeName)) return null;
|
|
265
|
+
|
|
266
|
+
// Fast/normal lookup first (assembly-qualified or plain type name).
|
|
264
267
|
var fqn = string.IsNullOrEmpty(assemblyName) ? typeName! : $"{typeName}, {assemblyName}";
|
|
265
|
-
var t
|
|
268
|
+
var t = Type.GetType(fqn);
|
|
266
269
|
if (t is not null) return t;
|
|
270
|
+
|
|
271
|
+
t = Type.GetType(typeName);
|
|
272
|
+
if (t is not null) return t;
|
|
273
|
+
|
|
274
|
+
// Last segment (type name without namespace) used for loose matching below.
|
|
275
|
+
var lastDot = typeName.LastIndexOf('.');
|
|
276
|
+
var shortName = lastDot >= 0 ? typeName[(lastDot + 1)..] : typeName;
|
|
277
|
+
|
|
278
|
+
// Search loaded assemblies quickly; prefer asm.GetType which is inexpensive.
|
|
267
279
|
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
|
268
280
|
{
|
|
269
|
-
|
|
270
|
-
|
|
281
|
+
try
|
|
282
|
+
{
|
|
283
|
+
t = asm.GetType(typeName);
|
|
284
|
+
if (t is not null) return t;
|
|
285
|
+
|
|
286
|
+
// Fall back to scanning exported types only when necessary. Some
|
|
287
|
+
// assemblies throw on GetTypes() (ReflectionTypeLoadException) so
|
|
288
|
+
// we catch and continue.
|
|
289
|
+
foreach (var ty in asm.GetTypes())
|
|
290
|
+
{
|
|
291
|
+
if (string.Equals(ty.FullName, typeName, StringComparison.Ordinal)
|
|
292
|
+
|| string.Equals(ty.Name, shortName, StringComparison.Ordinal)
|
|
293
|
+
|| (lastDot < 0 && ty.Namespace != null && ty.Namespace == typeName))
|
|
294
|
+
{
|
|
295
|
+
return ty;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
catch (ReflectionTypeLoadException) { }
|
|
300
|
+
catch { }
|
|
271
301
|
}
|
|
302
|
+
|
|
303
|
+
// If an assembly name was provided try loading it explicitly and repeat
|
|
304
|
+
// the above search inside that assembly only (less work than scanning all).
|
|
272
305
|
if (!string.IsNullOrEmpty(assemblyName))
|
|
273
306
|
{
|
|
274
|
-
try
|
|
307
|
+
try
|
|
308
|
+
{
|
|
309
|
+
var asm = Assembly.Load(assemblyName);
|
|
310
|
+
if (asm is not null)
|
|
311
|
+
{
|
|
312
|
+
t = asm.GetType(typeName!);
|
|
313
|
+
if (t is not null) return t;
|
|
314
|
+
try
|
|
315
|
+
{
|
|
316
|
+
foreach (var ty in asm.GetTypes())
|
|
317
|
+
{
|
|
318
|
+
if (string.Equals(ty.FullName, typeName, StringComparison.Ordinal)
|
|
319
|
+
|| string.Equals(ty.Name, shortName, StringComparison.Ordinal)
|
|
320
|
+
|| (lastDot < 0 && ty.Namespace != null && ty.Namespace == typeName))
|
|
321
|
+
{
|
|
322
|
+
return ty;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch (ReflectionTypeLoadException) { }
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch { }
|
|
275
330
|
}
|
|
276
|
-
|
|
331
|
+
|
|
332
|
+
return null;
|
|
277
333
|
}
|
|
278
334
|
|
|
279
335
|
private static MethodInfo? FindMethodCore(Type type, string name, int argCount, BindingFlags flags)
|