Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #1380 (remove resurrect logic) #1469

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions src/WinRT.Runtime/ComWrappersSupport.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ internal static unsafe InspectableInfo GetInspectableInfo(IntPtr pThis)
// We need to do the same thing for System.Type because there can be multiple WUX.Interop.TypeName's
// for a single System.Type.

// Resurrect IWinRTObject's disposed IObjectReferences, if necessary
if (rcw is IWinRTObject winrtObj)
{
winrtObj.Resurrect();
}

return rcw switch
{
ABI.System.Nullable nt => (T)nt.Value,
Expand Down Expand Up @@ -161,15 +155,7 @@ public static void RegisterObjectForInterface(object obj, IntPtr thisPtr) =>

public static object TryRegisterObjectForInterface(object obj, IntPtr thisPtr)
{
var rcw = ComWrappers.GetOrRegisterObjectForComInstance(thisPtr, CreateObjectFlags.TrackerObject, obj);

// Resurrect IWinRTObject's disposed IObjectReferences, if necessary
var target = rcw is Delegate del ? del.Target : rcw;
if (target is IWinRTObject winrtObj)
{
winrtObj.Resurrect();
}
return rcw;
return ComWrappers.GetOrRegisterObjectForComInstance(thisPtr, CreateObjectFlags.TrackerObject, obj);
}

public static IObjectReference CreateCCWForObject(object obj)
Expand Down
18 changes: 0 additions & 18 deletions src/WinRT.Runtime/IWinRTObject.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,5 @@ object GetOrCreateTypeHelperData(RuntimeTypeHandle type, Func<object> helperData
{
return AdditionalTypeData.GetOrAdd(type, (type) => helperDataFactory());
}

internal void Resurrect()
{
if (NativeObject.Resurrect())
{
foreach (var cached in QueryInterfaceCache)
{
cached.Value.Resurrect();
}

// Delegates store their agile reference as an additional type data.
// These should be recreated when instances are resurrect.
if (AdditionalTypeData.TryGetValue(typeof(AgileReference).TypeHandle, out var agileObj))
{
AdditionalTypeData.TryUpdate(typeof(AgileReference).TypeHandle, new AgileReference(NativeObject), agileObj);
}
}
}
}
}
Loading
Loading