@nativescript/windows 0.1.0-alpha.51 → 0.1.0-alpha.52

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.
@@ -245,11 +245,20 @@ public static partial class Bridge
245
245
  {
246
246
  const BindingFlags inst = BindingFlags.Public | BindingFlags.Instance;
247
247
  const BindingFlags stat = BindingFlags.Public | BindingFlags.Static;
248
+
249
+ var instProps = t.GetProperties(inst);
250
+ var statProps = t.GetProperties(stat);
251
+
248
252
  return DispatchResult.Members(
249
- t.GetMethods(inst).Where(m => !m.IsSpecialName).Select(m => m.Name).Distinct().ToArray(),
250
- t.GetProperties(inst).Select(p => p.Name).Distinct().ToArray(),
251
- t.GetMethods(stat).Where(m => !m.IsSpecialName).Select(m => m.Name).Distinct().ToArray(),
252
- t.GetProperties(stat).Select(p => p.Name).Distinct().ToArray());
253
+ methods: t.GetMethods(inst).Where(m => !m.IsSpecialName).Select(m => m.Name).Distinct().ToArray(),
254
+ props: instProps.Where(p => p.GetGetMethod() != null).Select(p => p.Name).Distinct().ToArray(),
255
+ staticMethods: t.GetMethods(stat).Where(m => !m.IsSpecialName).Select(m => m.Name).Distinct().ToArray(),
256
+ staticProps: statProps.Where(p => p.GetGetMethod() != null).Select(p => p.Name).Distinct().ToArray(),
257
+ readonlyProps: instProps.Where(p => p.GetGetMethod() != null && p.GetSetMethod() == null).Select(p => p.Name).Distinct().ToArray(),
258
+ readonlyStaticProps: statProps.Where(p => p.GetGetMethod() != null && p.GetSetMethod() == null).Select(p => p.Name).Distinct().ToArray(),
259
+ writeonlyProps: instProps.Where(p => p.GetGetMethod() == null && p.GetSetMethod() != null).Select(p => p.Name).Distinct().ToArray(),
260
+ writeonlyStaticProps: statProps.Where(p => p.GetGetMethod() == null && p.GetSetMethod() != null).Select(p => p.Name).Distinct().ToArray()
261
+ );
253
262
  }
254
263
 
255
264
  internal static Type? ResolveType(string? assemblyName, string? typeName)
@@ -288,12 +297,14 @@ public static partial class Bridge
288
297
  // we catch and continue.
289
298
  foreach (var ty in asm.GetTypes())
290
299
  {
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
- {
300
+ if (string.Equals(ty.FullName, typeName, StringComparison.Ordinal))
301
+ return ty;
302
+ // Short-name match only when input has no namespace prefix (e.g. "Stopwatch").
303
+ // Guarding on lastDot < 0 prevents matching unrelated types in other namespaces
304
+ // (e.g. "NativeScript.Widgets.FlexboxLayout" must not match a different
305
+ // FlexboxLayout that happens to live in another namespace).
306
+ if (lastDot < 0 && string.Equals(ty.Name, shortName, StringComparison.Ordinal))
295
307
  return ty;
296
- }
297
308
  }
298
309
  }
299
310
  catch (ReflectionTypeLoadException) { }
@@ -315,12 +326,10 @@ public static partial class Bridge
315
326
  {
316
327
  foreach (var ty in asm.GetTypes())
317
328
  {
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
- {
329
+ if (string.Equals(ty.FullName, typeName, StringComparison.Ordinal))
330
+ return ty;
331
+ if (lastDot < 0 && string.Equals(ty.Name, shortName, StringComparison.Ordinal))
322
332
  return ty;
323
- }
324
333
  }
325
334
  }
326
335
  catch (ReflectionTypeLoadException) { }
@@ -51,24 +51,13 @@ public static partial class Bridge
51
51
 
52
52
  // Returns a JSON object mapping top-level namespace roots (e.g. "NativeScript")
53
53
  // to the assembly simple-name that most likely contains that namespace's types.
54
- // This probes the application base directory and libs/ for assemblies and
55
- // inspects exported types. The result is safe-to-call and tolerant of
56
- // non-.NET DLLs.
54
+ // Reuses s_assemblySearchDirs so plugin and NuGet assemblies are included.
57
55
  public static string GetNamespaceAssemblyMapJson()
58
56
  {
59
57
  var map = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
60
58
  try
61
59
  {
62
- var baseDir = AppContext.BaseDirectory ?? AppDomain.CurrentDomain.BaseDirectory;
63
- var dirs = new List<string> { baseDir };
64
- var libs = Path.Combine(baseDir, "libs");
65
- if (Directory.Exists(libs))
66
- {
67
- dirs.Add(libs);
68
- try { dirs.AddRange(Directory.GetDirectories(libs, "*", SearchOption.AllDirectories)); } catch { }
69
- }
70
-
71
- foreach (var dir in dirs.Where(d => !string.IsNullOrEmpty(d) && Directory.Exists(d)))
60
+ foreach (var dir in s_assemblySearchDirs.Where(Directory.Exists))
72
61
  {
73
62
  try
74
63
  {
@@ -115,12 +104,40 @@ public static partial class Bridge
115
104
  {
116
105
  var baseDir = AppContext.BaseDirectory ?? AppDomain.CurrentDomain.BaseDirectory;
117
106
  var dirs = new List<string> { baseDir };
107
+
108
+ // libs/ subtree relative to the bridge's own directory.
118
109
  var libs = Path.Combine(baseDir, "libs");
119
110
  if (Directory.Exists(libs))
120
111
  {
121
112
  dirs.Add(libs);
122
113
  try { dirs.AddRange(Directory.GetDirectories(libs, "*", SearchOption.AllDirectories)); } catch { }
123
114
  }
115
+
116
+ // The bridge DLL lives at dotnet-bridge/publish/ inside the app output root.
117
+ // Plugin assemblies (added via plugin.props) land at plugins/**/*.dll and NuGet
118
+ // assemblies land at the app output root itself — both outside the bridge subtree.
119
+ // Use the host process directory to reach them.
120
+ try
121
+ {
122
+ var processDir = Path.GetDirectoryName(
123
+ System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName);
124
+ if (!string.IsNullOrEmpty(processDir))
125
+ {
126
+ dirs.Add(processDir);
127
+
128
+ // plugins/ subtree: CLI-managed plugin DLLs live here.
129
+ var pluginsDir = Path.Combine(processDir, "plugins");
130
+ if (Directory.Exists(pluginsDir))
131
+ try { dirs.AddRange(Directory.GetDirectories(pluginsDir, "*", SearchOption.AllDirectories)); } catch { }
132
+
133
+ // libs/ relative to the app root (alternative convention).
134
+ var processLibs = Path.Combine(processDir, "libs");
135
+ if (Directory.Exists(processLibs))
136
+ try { dirs.AddRange(Directory.GetDirectories(processLibs, "*", SearchOption.AllDirectories)); } catch { }
137
+ }
138
+ }
139
+ catch { }
140
+
124
141
  s_assemblySearchDirs = dirs.Where(d => !string.IsNullOrEmpty(d)).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
125
142
  AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
126
143
  }
@@ -71,14 +71,22 @@ internal readonly struct DispatchResult
71
71
  private readonly string[]? _properties;
72
72
  private readonly string[]? _staticMethods;
73
73
  private readonly string[]? _staticProperties;
74
+ private readonly string[]? _readonlyProperties;
75
+ private readonly string[]? _readonlyStaticProperties;
76
+ private readonly string[]? _writeonlyProperties;
77
+ private readonly string[]? _writeonlyStaticProperties;
74
78
 
75
79
  private DispatchResult(DispatchKind kind, object? value, Type? type, int handle,
76
80
  string? typeName, string[]? methods, string[]? props,
77
- string[]? staticMethods, string[]? staticProps)
81
+ string[]? staticMethods, string[]? staticProps,
82
+ string[]? readonlyProps = null, string[]? readonlyStaticProps = null,
83
+ string[]? writeonlyProps = null, string[]? writeonlyStaticProps = null)
78
84
  {
79
85
  _kind = kind; _value = value; _type = type; _handle = handle;
80
86
  _typeName = typeName; _methods = methods; _properties = props;
81
87
  _staticMethods = staticMethods; _staticProperties = staticProps;
88
+ _readonlyProperties = readonlyProps; _readonlyStaticProperties = readonlyStaticProps;
89
+ _writeonlyProperties = writeonlyProps; _writeonlyStaticProperties = writeonlyStaticProps;
82
90
  }
83
91
 
84
92
  public static DispatchResult Primitive(object value, Type type)
@@ -91,8 +99,12 @@ internal readonly struct DispatchResult
91
99
  => new(DispatchKind.Collection, items, null, 0, null, null, null, null, null);
92
100
 
93
101
  public static DispatchResult Members(
94
- string[] methods, string[] props, string[] staticMethods, string[] staticProps)
95
- => new(DispatchKind.Members, null, null, 0, null, methods, props, staticMethods, staticProps);
102
+ string[] methods, string[] props, string[] staticMethods, string[] staticProps,
103
+ string[] readonlyProps, string[] readonlyStaticProps,
104
+ string[] writeonlyProps, string[] writeonlyStaticProps)
105
+ => new(DispatchKind.Members, null, null, 0, null,
106
+ methods, props, staticMethods, staticProps,
107
+ readonlyProps, readonlyStaticProps, writeonlyProps, writeonlyStaticProps);
96
108
 
97
109
  internal int HandleId() => _handle;
98
110
 
@@ -126,10 +138,14 @@ internal readonly struct DispatchResult
126
138
 
127
139
  case DispatchKind.Members:
128
140
  w.WriteStartObject();
129
- WriteStringArray(w, "methods"u8, _methods!);
130
- WriteStringArray(w, "properties"u8, _properties!);
131
- WriteStringArray(w, "staticMethods"u8, _staticMethods!);
132
- WriteStringArray(w, "staticProperties"u8, _staticProperties!);
141
+ WriteStringArray(w, "methods"u8, _methods!);
142
+ WriteStringArray(w, "properties"u8, _properties!);
143
+ WriteStringArray(w, "staticMethods"u8, _staticMethods!);
144
+ WriteStringArray(w, "staticProperties"u8, _staticProperties!);
145
+ WriteStringArray(w, "readonlyProperties"u8, _readonlyProperties!);
146
+ WriteStringArray(w, "readonlyStaticProperties"u8, _readonlyStaticProperties!);
147
+ WriteStringArray(w, "writeonlyProperties"u8, _writeonlyProperties!);
148
+ WriteStringArray(w, "writeonlyStaticProperties"u8,_writeonlyStaticProperties!);
133
149
  w.WriteEndObject();
134
150
  break;
135
151
  }
@@ -185,6 +201,10 @@ internal readonly struct DispatchResult
185
201
  WriteStringArrayBin(ref w, _properties!);
186
202
  WriteStringArrayBin(ref w, _staticMethods!);
187
203
  WriteStringArrayBin(ref w, _staticProperties!);
204
+ WriteStringArrayBin(ref w, _readonlyProperties!);
205
+ WriteStringArrayBin(ref w, _readonlyStaticProperties!);
206
+ WriteStringArrayBin(ref w, _writeonlyProperties!);
207
+ WriteStringArrayBin(ref w, _writeonlyStaticProperties!);
188
208
  break;
189
209
  }
190
210
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/windows",
3
- "version": "0.1.0-alpha.51",
3
+ "version": "0.1.0-alpha.52",
4
4
  "description": "NativeScript for using Windows v8",
5
5
  "repository": {
6
6
  "type": "git",