@nativescript/windows 0.1.0-alpha.53 → 0.1.0-alpha.55

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.
@@ -115,6 +115,12 @@ internal ref struct BinWriter(ArrayBufferWriter<byte> buf)
115
115
  _buf.Advance(4);
116
116
  }
117
117
 
118
+ public void WriteI64(long v)
119
+ {
120
+ BinaryPrimitives.WriteInt64LittleEndian(_buf.GetSpan(8), v);
121
+ _buf.Advance(8);
122
+ }
123
+
118
124
  public void WriteF64(double v)
119
125
  {
120
126
  BinaryPrimitives.WriteDoubleLittleEndian(_buf.GetSpan(8), v);
@@ -158,12 +158,23 @@ public static partial class Bridge
158
158
  s_handles.TryGetValue(hr.Id, out var obj);
159
159
  return obj;
160
160
  }
161
- if (value is WinRtRef wr && wr.Ptr != 0)
161
+ if (value is WinRtRef wr)
162
162
  {
163
- // Marshal.GetObjectForIUnknown calls AddRef internally; the RCW will
164
- // Release when GC'd.
165
- try { return Marshal.GetObjectForIUnknown(new IntPtr(wr.Ptr)); }
166
- catch { return null; }
163
+ if (wr.Ptr == 0) return null;
164
+ var nativePtr = new IntPtr((long)wr.Ptr);
165
+ // 1. Typed QI first: works for COM/CsWinRT interface types that carry a
166
+ // [Guid] attribute. More precise than a generic RCW for strongly-typed
167
+ // parameters such as Windows.UI.Xaml.UIElement.
168
+ if (targetType != typeof(object) && targetType.GUID != Guid.Empty)
169
+ {
170
+ try { return Marshal.GetTypedObjectForIUnknown(nativePtr, targetType); }
171
+ catch { }
172
+ }
173
+ // 2. Generic RCW: .NET WinRT interop calls IInspectable::GetRuntimeClassName
174
+ // and projects to the appropriate CsWinRT type automatically.
175
+ // Do NOT swallow the exception — a null return silently breaks the call
176
+ // downstream; a thrown exception surfaces a meaningful error instead.
177
+ return Marshal.GetObjectForIUnknown(nativePtr);
167
178
  }
168
179
  if (value.GetType() == targetType) return value;
169
180
  try { return Convert.ChangeType(value, targetType); }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/windows",
3
- "version": "0.1.0-alpha.53",
3
+ "version": "0.1.0-alpha.55",
4
4
  "description": "NativeScript for using Windows v8",
5
5
  "repository": {
6
6
  "type": "git",